/****** Object:  Table [dbo].[AccessFacilities]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AccessFacilities]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[AccessFacilities](
	[FacCode] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_AccessFacilities] PRIMARY KEY CLUSTERED 
(
	[FacCode] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[AccessLevels]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AccessLevels]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[AccessLevels](
	[AccessID] [int] NOT NULL,
	[AccessName] [nvarchar](100) NULL,
 CONSTRAINT [PK_AccessLevels] PRIMARY KEY CLUSTERED 
(
	[AccessID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[Activities]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Activities]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Activities](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](max) NULL,
	[Description] [nvarchar](max) NULL,
	[Comments] [nvarchar](max) NULL,
 CONSTRAINT [PK_dbo.Activities] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[ANCForm]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ANCForm]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ANCForm](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[MetadataId] [int] NOT NULL,
	[FacilityCode] [varchar](50) NULL,
	[ReportDate] [datetime] NOT NULL,
	[LessThan20] [bit] NOT NULL,
	[C_1] [int] NULL,
	[C_3] [int] NULL,
	[C_7] [int] NULL,
	[C_8] [int] NULL,
	[C_9] [int] NULL,
	[C_10] [int] NULL,
	[HudhurioLaKwanza_2id] [int] NULL,
	[VidokezoVyaHatari_4id] [int] NULL,
	[PMTCT_5id] [int] NULL,
	[Malaria_6id] [int] NULL,
	[Comments] [nvarchar](1000) NULL,
	[Year]  AS (datepart(year,[ReportDate])),
	[Month]  AS (datepart(month,[ReportDate])),
 CONSTRAINT [PK_ANCForm] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[ANCForm_HudhurioLaKwanza]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ANCForm_HudhurioLaKwanza]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ANCForm_HudhurioLaKwanza](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[MetadataId] [int] NOT NULL,
	[FacilityCode] [varchar](50) NULL,
	[ReportDate] [datetime] NOT NULL,
	[LessThan20] [bit] NOT NULL,
	[C_2a] [int] NOT NULL,
	[C_2b] [int] NOT NULL,
	[C_2c] [int] NOT NULL,
	[C_2d] [int] NOT NULL,
	[C_2e] [int] NOT NULL,
	[C_2f] [int] NOT NULL,
	[C_2g] [int] NOT NULL,
	[Year]  AS (datepart(year,[ReportDate])),
	[Month]  AS (datepart(month,[ReportDate])),
	[Comments] [nvarchar](1000) NULL,
 CONSTRAINT [PK_ANCForm_HudhurioLaKwanza] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[ANCForm_Malaria]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ANCForm_Malaria]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ANCForm_Malaria](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[MetadataId] [int] NOT NULL,
	[FacilityCode] [varchar](50) NULL,
	[ReportDate] [datetime] NOT NULL,
	[LessThan20] [bit] NOT NULL,
	[C_6a] [int] NOT NULL,
	[C_6b] [int] NOT NULL,
	[C_6c] [int] NOT NULL,
	[C_6d] [int] NOT NULL,
	[C_6e] [int] NOT NULL,
	[Comments] [nvarchar](1000) NULL,
	[Year]  AS (datepart(year,[ReportDate])),
	[Month]  AS (datepart(month,[ReportDate])),
 CONSTRAINT [PK_ANCForm_Malaria] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[ANCForm_PMTCT]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ANCForm_PMTCT]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ANCForm_PMTCT](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[MetadataId] [int] NOT NULL,
	[FacilityCode] [varchar](50) NULL,
	[ReportDate] [datetime] NOT NULL,
	[LessThan20] [bit] NOT NULL,
	[C_5a] [int] NOT NULL,
	[C_5b] [int] NOT NULL,
	[C_5c] [int] NOT NULL,
	[C_5d] [int] NOT NULL,
	[C_5e] [int] NOT NULL,
	[C_5f] [int] NOT NULL,
	[C_5g] [int] NOT NULL,
	[C_5h] [int] NOT NULL,
	[C_5i] [int] NOT NULL,
	[C_5j] [int] NOT NULL,
	[C_5k] [int] NOT NULL,
	[C_5l] [int] NOT NULL,
	[C_5m] [int] NOT NULL,
	[Comments] [nvarchar](1000) NULL,
	[Year]  AS (datepart(year,[ReportDate])),
	[Month]  AS (datepart(month,[ReportDate])),
	[C_5n] [int] NOT NULL,
	[C_5o] [int] NOT NULL,
	[C_5p] [int] NOT NULL,
	[C_5q] [int] NOT NULL,
	[C_5x] [int] NULL,
	[C_5y] [int] NULL,
 CONSTRAINT [PK_ANCForm_PMTCT] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[ANCForm_VidokezoVyaHatari]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ANCForm_VidokezoVyaHatari]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ANCForm_VidokezoVyaHatari](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[MetadataId] [int] NOT NULL,
	[FacilityCode] [varchar](50) NULL,
	[ReportDate] [datetime] NOT NULL,
	[LessThan20] [bit] NOT NULL,
	[C_4a] [int] NOT NULL,
	[C_4b] [int] NOT NULL,
	[C_4c] [int] NOT NULL,
	[C_4d] [int] NOT NULL,
	[C_4e] [int] NOT NULL,
	[C_4f] [int] NOT NULL,
	[C_4g] [int] NOT NULL,
	[C_4h] [int] NOT NULL,
	[C_4i] [int] NOT NULL,
	[C_4j] [int] NOT NULL,
	[C_4k] [int] NOT NULL,
	[Comments] [nvarchar](1000) NULL,
	[Year]  AS (datepart(year,[ReportDate])),
	[Month]  AS (datepart(month,[ReportDate])),
	[C_4l] [int] NOT NULL,
	[C_4m] [int] NOT NULL,
	[C_4n] [int] NOT NULL,
	[C_4o] [int] NOT NULL,
	[C_4p] [int] NOT NULL,
	[C_4q] [int] NOT NULL,
	[C_4r] [int] NOT NULL,
 CONSTRAINT [PK_ANCForm_VidokezoVyaHatari] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[ANCFormMetadata]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ANCFormMetadata]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ANCFormMetadata](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[InputMethodId] [int] NOT NULL,
	[TimeReceived] [datetime] NOT NULL,
	[Sender] [nvarchar](255) NULL,
	[SenderPhoneNumber] [nvarchar](50) NULL,
	[TextMessage] [nvarchar](1000) NULL,
	[MoreInformation] [nvarchar](1000) NULL,
	[PreviousReportId] [int] NULL,
 CONSTRAINT [PK_Table_2] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[ApprovedSMSCells]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ApprovedSMSCells]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ApprovedSMSCells](
	[ApprovedCellNo] [int] IDENTITY(1,1) NOT NULL,
	[CellNum] [varchar](250) NULL,
	[Name] [varchar](250) NULL,
	[LangID] [int] NULL,
	[SendSMS] [bit] NOT NULL,
	[FacCode] [varchar](50) NULL,
	[Email] [nvarchar](255) NULL,
	[TitleID] [int] NULL,
	[CreatedBy] [int] NULL,
	[CreateDate] [datetime] NULL,
	[UpdatedBy] [int] NULL,
	[UpdateDate] [datetime] NULL,
	[DeletedBy] [int] NULL,
	[DeleteDate] [datetime] NULL,
	[Deleted] [bit] NULL,
 CONSTRAINT [PK_ApprovedSMSCells] PRIMARY KEY CLUSTERED 
(
	[ApprovedCellNo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Assistance]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Assistance]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Assistance](
	[AssistanceID] [int] IDENTITY(1,1) NOT NULL,
	[ApprovedCellNo] [int] NOT NULL,
	[FacCode] [nvarchar](50) NULL,
	[DistrictID] [int] NULL,
	[RegionID] [int] NULL,
 CONSTRAINT [PK_Assistance] PRIMARY KEY CLUSTERED 
(
	[AssistanceID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[AssociatedEarlyInfantDiagnosis]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AssociatedEarlyInfantDiagnosis]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[AssociatedEarlyInfantDiagnosis](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[FacilityCode] [varchar](50) NOT NULL,
	[TimeframeId] [int] NOT NULL,
	[CounselingAndTestingId] [int] NOT NULL,
	[CreatedByUserId] [int] NOT NULL,
	[DateCreated] [datetime] NOT NULL,
	[UpdatedByUserId] [int] NULL,
	[UpdateDate] [datetime] NULL,
	[MC10_Female] [int] NOT NULL,
	[MC10_Male] [int] NOT NULL,
	[MC11_Female] [int] NOT NULL,
	[MC11_Male] [int] NOT NULL,
	[MC12_Female] [int] NOT NULL,
	[MC12_Male] [int] NOT NULL,
	[MC13_Female] [int] NOT NULL,
	[MC13_Male] [int] NOT NULL,
	[MC14_Female] [int] NOT NULL,
	[MC14_Male] [int] NOT NULL,
	[MC15_Female] [int] NOT NULL,
	[MC15_Male] [int] NOT NULL,
	[MC10] [int] NOT NULL,
	[MC11] [int] NOT NULL,
	[MC12] [int] NOT NULL,
	[MC13] [int] NOT NULL,
	[MC14] [int] NOT NULL,
	[MC15] [int] NOT NULL,
 CONSTRAINT [PK_dbo.AssociatedEarlyInfantDiagnosis] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[AutoReminderDistricts]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AutoReminderDistricts]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[AutoReminderDistricts](
	[DistrictId] [int] NOT NULL,
 CONSTRAINT [PK_AutoReminderDistricts] PRIMARY KEY CLUSTERED 
(
	[DistrictId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[AutoReminderFacilities]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AutoReminderFacilities]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[AutoReminderFacilities](
	[FacilityCode] [varchar](50) NOT NULL,
 CONSTRAINT [PK_AutoReminderFacilities] PRIMARY KEY CLUSTERED 
(
	[FacilityCode] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[AutoReminderRegions]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AutoReminderRegions]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[AutoReminderRegions](
	[RegionId] [int] NOT NULL,
 CONSTRAINT [PK_AutoReminderRegions] PRIMARY KEY CLUSTERED 
(
	[RegionId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[AutoReminderReportMessageTemplates]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AutoReminderReportMessageTemplates]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[AutoReminderReportMessageTemplates](
	[ReportId] [int] NOT NULL,
	[MessageTemplate] [nvarchar](1000) NOT NULL,
	[EnableAutoReminder] [bit] NOT NULL,
 CONSTRAINT [PK_AutoReminderReportMessageTemplates] PRIMARY KEY CLUSTERED 
(
	[ReportId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[BACKUP__MigrationHistory]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[BACKUP__MigrationHistory]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[BACKUP__MigrationHistory](
	[MigrationId] [nvarchar](150) NOT NULL,
	[ContextKey] [nvarchar](300) NOT NULL,
	[Model] [varbinary](max) NOT NULL,
	[ProductVersion] [nvarchar](32) NOT NULL,
 CONSTRAINT [PK_dbo.__MigrationHistory2] PRIMARY KEY CLUSTERED 
(
	[MigrationId] ASC,
	[ContextKey] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[BlockedNumbers]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[BlockedNumbers]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[BlockedNumbers](
	[PhoneNumber] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_BlockedNumbers] PRIMARY KEY CLUSTERED 
(
	[PhoneNumber] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[CalendarHolidays]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CalendarHolidays]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[CalendarHolidays](
	[CalendarYear] [int] NOT NULL,
	[HolidayDate] [nvarchar](6) NOT NULL,
	[HolidayName] [nvarchar](1000) NOT NULL,
 CONSTRAINT [PK_CalendarHolidays] PRIMARY KEY CLUSTERED 
(
	[CalendarYear] ASC,
	[HolidayDate] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[CategorizingQueries]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CategorizingQueries]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[CategorizingQueries](
	[QueryID] [int] NOT NULL,
	[QueryCategoryID] [int] NOT NULL,
	[CreateDate] [smalldatetime] NULL,
	[CreatedByUser] [int] NULL,
 CONSTRAINT [PK_CategorizingQueries] PRIMARY KEY CLUSTERED 
(
	[QueryID] ASC,
	[QueryCategoryID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[CDCTargets]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CDCTargets]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[CDCTargets](
	[FacilityCode] [varchar](50) NOT NULL,
	[COPYear] [nvarchar](4) NOT NULL,
	[TZ_CARE_NGI_Direct] [bit] NULL,
	[TZ_CARE_ServiceType] [nvarchar](10) NULL,
	[C21D_FemaleLT15] [int] NULL,
	[C21D_FemaleGT15] [int] NULL,
	[C21D_MaleLT15] [int] NULL,
	[C21D_MaleGT15] [int] NULL,
	[FN_THER_ServiceType] [nvarchar](10) NULL,
	[FN_THER_Num] [int] NULL,
	[FN_THER_Denom] [int] NULL,
	[TB_HIV_NGI_Direct] [bit] NULL,
	[TB_HIV_ServiceType] [nvarchar](10) NULL,
	[TB_HIV_Num] [int] NULL,
	[TB_HIV_Denom] [int] NULL,
	[TX_NGI_Direct] [bit] NULL,
	[TX_ServiceType] [nvarchar](10) NULL,
	[TX_NEW_FemaleLT1] [int] NULL,
	[TX_NEW_FemaleLT15] [int] NULL,
	[TX_NEW_FemaleGT15] [int] NULL,
	[TX_NEW_MaleLT1] [int] NULL,
	[TX_NEW_MaleLT15] [int] NULL,
	[TX_NEW_MaleGT15] [int] NULL,
	[TX_NEW_PregnantWomen] [int] NULL,
	[TX_CURR_MaleLT1] [int] NULL,
	[TX_CURR_MaleLT15] [int] NULL,
	[TX_CURR_MaleGT15] [int] NULL,
	[TX_CURR_FemaleLT1] [int] NULL,
	[TX_CURR_FemaleLT15] [int] NULL,
	[TX_CURR_FemaleGT15] [int] NULL,
	[TX_RET_Num_0_4] [int] NULL,
	[TX_RET_Num_5_15] [int] NULL,
	[TX_RET_Num_LT15] [int] NULL,
	[TX_RET_Num_PregnantWomen] [int] NULL,
	[TX_RET_Denom_0_4] [int] NULL,
	[TX_RET_Denom_5_15] [int] NULL,
	[TX_RET_Denom_LT15] [int] NULL,
	[TX_RET_Denom_PregnantWomen] [int] NULL,
	[PMTCT_NGI_Direct] [bit] NULL,
	[PMTCT_ServiceType] [nvarchar](10) NULL,
	[PMTCT_STAT_TestedPositive] [int] NULL,
	[PMTCT_STAT_TestedNegative] [int] NULL,
	[PMTCT_KnownPositive] [int] NULL,
	[PMTCT_NewClients] [int] NULL,
	[PMTCT_ARV_OptionB_NewOnART] [int] NULL,
	[PMTCT_ARV_OptionB_AlreadyOnART] [int] NULL,
	[PMTCT_ARV_MaternalAZT] [int] NULL,
	[PMTCT_ARV_Denom_PregnantWomenIdentified] [int] NULL,
	[PMTCT_EID_TestedLT2] [int] NULL,
	[PMTCT_EID_TestedBT2_12] [int] NULL,
	[PMTCT_EID_TestedPositiveLT2] [int] NULL,
	[PMTCT_EID_TestedPositiveBT2_12] [int] NULL,
	[P13D_ProvideANCServices] [bit] NULL,
	[HTC_NGI_Direct] [bit] NULL,
	[HTC_ServiceType] [nvarchar](10) NULL,
	[HTC_TST_MaleLT1] [int] NULL,
	[HTC_TST_MaleBT1_4] [int] NULL,
	[HTC_TST_MaleBT5_9] [int] NULL,
	[HTC_TST_MaleBT10_14] [int] NULL,
	[HTC_TST_MaleBT15_19] [int] NULL,
	[HTC_TST_MaleBT20_24] [int] NULL,
	[HTC_TST_MaleBT25_49] [int] NULL,
	[HTC_TST_MaleGT50] [int] NULL,
	[HTC_TST_FemaleLT1] [int] NULL,
	[HTC_TST_FemaleBT1_4] [int] NULL,
	[HTC_TST_FemaleBT5_9] [int] NULL,
	[HTC_TST_FemaleBT10_14] [int] NULL,
	[HTC_TST_FemaleBT15_19] [int] NULL,
	[HTC_TST_FemaleBT20_24] [int] NULL,
	[HTC_TST_FemaleBT25_49] [int] NULL,
	[HTC_TST_FemaleGT50] [int] NULL,
	[HTC_TST_ByTestResultPositive] [int] NULL,
	[HTC_TST_ByTestResultNegative] [int] NULL,
	[HTC_TST_ByCoupleIndividualPositive] [int] NULL,
	[HTC_TST_ByCoupleIndividualNegative] [int] NULL,
	[HTC_TST_ByCoupleCouplePositive] [int] NULL,
	[HTC_TST_ByCoupleCoupleNegative] [int] NULL,
	[TZ_CARE_FemaleLT1] [int] NULL,
	[TZ_CARE_FemaleBT1_4] [int] NULL,
	[TZ_CARE_FemaleBT5_9] [int] NULL,
	[TZ_CARE_FemaleBT10_14] [int] NULL,
	[TZ_CARE_FemaleBT15_19] [int] NULL,
	[TZ_CARE_FemaleBT20_24] [int] NULL,
	[TZ_CARE_FemaleBT25_49] [int] NULL,
	[TZ_CARE_FemaleGT50] [int] NULL,
	[TZ_CARE_MaleLT1] [int] NULL,
	[TZ_CARE_MaleBT1_4] [int] NULL,
	[TZ_CARE_MaleBT5_9] [int] NULL,
	[TZ_CARE_MaleBT10_14] [int] NULL,
	[TZ_CARE_MaleBT15_19] [int] NULL,
	[TZ_CARE_MaleBT20_24] [int] NULL,
	[TZ_CARE_MaleBT25_49] [int] NULL,
	[TZ_CARE_MaleGT50] [int] NULL,
	[TZ_NUT_FemaleLT1] [int] NULL,
	[TZ_NUT_FemaleBT1_4] [int] NULL,
	[TZ_NUT_FemaleBT5_14] [int] NULL,
	[TZ_NUT_FemaleBT15_17] [int] NULL,
	[TZ_NUT_FemaleGT18] [int] NULL,
	[TZ_NUT_MaleLT1] [int] NULL,
	[TZ_NUT_MaleBT1_4] [int] NULL,
	[TZ_NUT_MaleBT5_14] [int] NULL,
	[TZ_NUT_MaleBT15_17] [int] NULL,
	[TZ_NUT_MaleGT18] [int] NULL,
	[TZ_ECON_FemaleLT1] [int] NULL,
	[TZ_ECON_FemaleBT1_4] [int] NULL,
	[TZ_ECON_FemaleBT5_9] [int] NULL,
	[TZ_ECON_FemaleBT10_14] [int] NULL,
	[TZ_ECON_FemaleBT15_19] [int] NULL,
	[TZ_ECON_FemaleBT20_24] [int] NULL,
	[TZ_ECON_FemaleBT25_49] [int] NULL,
	[TZ_ECON_FemaleBT50_64] [int] NULL,
	[TZ_ECON_FemaleGT65] [int] NULL,
	[TZ_ECON_MaleLT1] [int] NULL,
	[TZ_ECON_MaleBT1_4] [int] NULL,
	[TZ_ECON_MaleBT5_9] [int] NULL,
	[TZ_ECON_MaleBT10_14] [int] NULL,
	[TZ_ECON_MaleBT15_19] [int] NULL,
	[TZ_ECON_MaleBT20_24] [int] NULL,
	[TZ_ECON_MaleBT25_49] [int] NULL,
	[TZ_ECON_MaleBT50_64] [int] NULL,
	[TZ_ECON_MaleGT65] [int] NULL,
	[TX_RET_Num_BreastFeeding] [int] NULL,
	[TX_RET_Denom_BreastFeeding] [int] NULL,
 CONSTRAINT [PK_dbo.CDCTargets] PRIMARY KEY CLUSTERED 
(
	[FacilityCode] ASC,
	[COPYear] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[CDCTargets1]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CDCTargets1]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[CDCTargets1](
	[FacilityCode] [varchar](50) NOT NULL,
	[COPYear] [nvarchar](4) NOT NULL,
	[HTC_NGI_Direct] [bit] NOT NULL,
	[HTC_ServiceType] [nvarchar](10) NULL,
	[HTC_TST_MaleLT1] [int] NULL,
	[HTC_TST_FemaleLT1] [int] NULL,
	[HTC_TST_MaleBT1_4] [int] NULL,
	[HTC_TST_FemaleBT1_4] [int] NULL,
	[HTC_TST_MaleBT5_9] [int] NULL,
	[HTC_TST_FemaleBT5_9] [int] NULL,
	[HTC_TST_MaleBT10_14] [int] NULL,
	[HTC_TST_FemaleBT10_14] [int] NULL,
	[HTC_TST_MaleBT15_19] [int] NULL,
	[HTC_TST_FemaleBT15_19] [int] NULL,
	[HTC_TST_MaleBT20_24] [int] NULL,
	[HTC_TST_FemaleBT20_24] [int] NULL,
	[HTC_TST_MaleBT25_49] [int] NULL,
	[HTC_TST_FemaleBT25_49] [int] NULL,
	[HTC_TST_MaleGT50] [int] NULL,
	[HTC_TST_FemaleGT50] [int] NULL,
	[HTC_TST_ByTestResultPositive] [int] NULL,
	[HTC_TST_ByTestResultNegative] [int] NULL,
	[HTC_TST_ByCoupleIndividualPositive] [int] NULL,
	[HTC_TST_ByCoupleIndividualNegative] [int] NULL,
	[HTC_TST_ByCoupleCouplePositive] [int] NULL,
	[HTC_TST_ByCoupleCoupleNegative] [int] NULL,
	[TZ_CARE_NGI_Direct] [bit] NULL,
	[TZ_CARE_ServiceType] [nvarchar](10) NULL,
	[C21D_MaleLT15] [int] NULL,
	[C21D_FemaleLT15] [int] NULL,
	[C21D_MaleGT15] [int] NULL,
	[C21D_FemaleGT15] [int] NULL,
	[TZ_CARE_MaleLT1] [int] NULL,
	[TZ_CARE_FemaleLT1] [int] NULL,
	[TZ_CARE_MaleBT1_4] [int] NULL,
	[TZ_CARE_FemaleBT1_4] [int] NULL,
	[TZ_CARE_MaleBT5_9] [int] NULL,
	[TZ_CARE_FemaleBT5_9] [int] NULL,
	[TZ_CARE_MaleBT10_14] [int] NULL,
	[TZ_CARE_FemaleBT10_14] [int] NULL,
	[TZ_CARE_MaleBT15_19] [int] NULL,
	[TZ_CARE_FemaleBT15_19] [int] NULL,
	[TZ_CARE_MaleBT20_24] [int] NULL,
	[TZ_CARE_FemaleBT20_24] [int] NULL,
	[TZ_CARE_MaleBT25_49] [int] NULL,
	[TZ_CARE_FemaleBT25_49] [int] NULL,
	[TZ_CARE_MaleGT50] [int] NULL,
	[TZ_CARE_FemaleGT50] [int] NULL,
	[TZ_NUT_MaleLT1] [int] NULL,
	[TZ_NUT_FemaleLT1] [int] NULL,
	[TZ_NUT_MaleBT1_4] [int] NULL,
	[TZ_NUT_FemaleBT1_4] [int] NULL,
	[TZ_NUT_MaleBT5_14] [int] NULL,
	[TZ_NUT_FemaleBT5_14] [int] NULL,
	[TZ_NUT_MaleBT15_17] [int] NULL,
	[TZ_NUT_FemaleBT15_17] [int] NULL,
	[TZ_NUT_MaleGT18] [int] NULL,
	[TZ_NUT_FemaleGT18] [int] NULL,
	[TZ_ECON_MaleLT1] [int] NULL,
	[TZ_ECON_FemaleLT1] [int] NULL,
	[TZ_ECON_MaleBT1_4] [int] NULL,
	[TZ_ECON_FemaleBT1_4] [int] NULL,
	[TZ_ECON_MaleBT5_9] [int] NULL,
	[TZ_ECON_FemaleBT5_9] [int] NULL,
	[TZ_ECON_MaleBT10_14] [int] NULL,
	[TZ_ECON_FemaleBT10_14] [int] NULL,
	[TZ_ECON_MaleBT15_19] [int] NULL,
	[TZ_ECON_FemaleBT15_19] [int] NULL,
	[TZ_ECON_MaleBT20_24] [int] NULL,
	[TZ_ECON_FemaleBT20_24] [int] NULL,
	[TZ_ECON_MaleBT25_49] [int] NULL,
	[TZ_ECON_FemaleBT25_49] [int] NULL,
	[TZ_ECON_MaleBT50_64] [int] NULL,
	[TZ_ECON_FemaleBT50_64] [int] NULL,
	[TZ_ECON_MaleGT65] [int] NULL,
	[TZ_ECON_FemaleGT65] [int] NULL,
	[FN_THER_ServiceType] [nvarchar](10) NULL,
	[FN_THER_Num] [int] NULL,
	[FN_THER_Denom] [int] NULL,
	[TB_HIV_NGI_Direct] [bit] NULL,
	[TB_HIV_ServiceType] [nvarchar](10) NULL,
	[TB_HIV_Num] [int] NULL,
	[TB_HIV_Denom] [int] NULL,
	[TX_NGI_Direct] [bit] NULL,
	[TX_ServiceType] [nvarchar](10) NULL,
	[TX_NEW_MaleLT1] [int] NULL,
	[TX_NEW_FemaleLT1] [int] NULL,
	[TX_NEW_MaleLT15] [int] NULL,
	[TX_NEW_FemaleLT15] [int] NULL,
	[TX_NEW_MaleGT15] [int] NULL,
	[TX_NEW_FemaleGT15] [int] NULL,
	[TX_NEW_PregnantWomen] [int] NULL,
	[TX_CURR_MaleLT1] [int] NULL,
	[TX_CURR_FemaleLT1] [int] NULL,
	[TX_CURR_MaleLT15] [int] NULL,
	[TX_CURR_FemaleLT15] [int] NULL,
	[TX_CURR_MaleGT15] [int] NULL,
	[TX_CURR_FemaleGT15] [int] NULL,
	[TX_RET_Num_0_4] [int] NULL,
	[TX_RET_Num_5_15] [int] NULL,
	[TX_RET_Num_LT15] [int] NULL,
	[TX_RET_Num_PregnantWomen] [int] NULL,
	[TX_RET_Num_BreastFeeding] [int] NULL,
	[TX_RET_Denom_0_4] [int] NULL,
	[TX_RET_Denom_5_15] [int] NULL,
	[TX_RET_Denom_LT15] [int] NULL,
	[TX_RET_Denom_PregnantWomen] [int] NULL,
	[TX_RET_Denom_BreastFeeding] [int] NULL,
	[PMTCT_NGI_Direct] [bit] NULL,
	[PMTCT_ServiceType] [nvarchar](10) NULL,
	[PMTCT_STAT_TestedPositive] [int] NULL,
	[PMTCT_STAT_TestedNegative] [int] NULL,
	[PMTCT_KnownPositive] [int] NULL,
	[PMTCT_NewClients] [int] NULL,
	[PMTCT_ARV_OptionB_NewOnART] [int] NULL,
	[PMTCT_ARV_OptionB_AlreadyOnART] [int] NULL,
	[PMTCT_ARV_MaternalAZT] [int] NULL,
	[PMTCT_ARV_Denom_PregnantWomenIdentified] [int] NULL,
	[PMTCT_EID_TestedLT2] [int] NULL,
	[PMTCT_EID_TestedBT2_12] [int] NULL,
	[PMTCT_EID_TestedPositiveLT2] [int] NULL,
	[PMTCT_EID_TestedPositiveBT2_12] [int] NULL,
	[P13D_ProvideANCServices] [bit] NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[CDCTargetsDemo]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CDCTargetsDemo]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[CDCTargetsDemo](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[FacilityCode] [varchar](50) NOT NULL,
	[COPYear] [nvarchar](4) NOT NULL,
	[TZ_CARE_NGI_Direct] [bit] NOT NULL,
	[TZ_CARE_ServiceType] [nvarchar](10) NULL,
	[C21D_FemaleLT15] [int] NULL,
	[C21D_FemaleGT15] [int] NULL,
	[C21D_MaleLT15] [int] NULL,
	[C21D_MaleGT15] [int] NULL,
	[FN_THER_ServiceType] [nvarchar](10) NULL,
	[FN_THER_Num] [int] NULL,
	[FN_THER_Denom] [int] NULL,
	[TB_HIV_NGI_Direct] [bit] NOT NULL,
	[TB_HIV_ServiceType] [nvarchar](10) NULL,
	[TB_HIV_Num] [int] NULL,
	[TB_HIV_Denom] [int] NULL,
	[TX_NGI_Direct] [bit] NOT NULL,
	[TX_ServiceType] [nvarchar](10) NULL,
	[TX_NEW_FemaleLT1] [int] NULL,
	[TX_NEW_FemaleLT15] [int] NULL,
	[TX_NEW_FemaleGT15] [int] NULL,
	[TX_NEW_MaleLT1] [int] NULL,
	[TX_NEW_MaleLT15] [int] NULL,
	[TX_NEW_MaleGT15] [int] NULL,
	[TX_NEW_PregnantWomen] [int] NULL,
	[TX_CURR_MaleLT1] [int] NULL,
	[TX_CURR_MaleLT15] [int] NULL,
	[TX_CURR_MaleGT15] [int] NULL,
	[TX_CURR_FemaleLT1] [int] NULL,
	[TX_CURR_FemaleLT15] [int] NULL,
	[TX_CURR_FemaleGT15] [int] NULL,
	[TX_RET_Num_0_4] [int] NULL,
	[TX_RET_Num_5_15] [int] NULL,
	[TX_RET_Num_LT15] [int] NULL,
	[TX_RET_Num_PregnantWomen] [int] NULL,
	[TX_RET_Denom_0_4] [int] NULL,
	[TX_RET_Denom_5_15] [int] NULL,
	[TX_RET_Denom_LT15] [int] NULL,
	[TX_RET_Denom_PregnantWomen] [int] NULL,
	[PMTCT_NGI_Direct] [bit] NOT NULL,
	[PMTCT_ServiceType] [nvarchar](10) NULL,
	[PMTCT_STAT_TestedPositive] [int] NULL,
	[PMTCT_STAT_TestedNegative] [int] NULL,
	[PMTCT_KnownPositive] [int] NULL,
	[PMTCT_NewClients] [int] NULL,
	[PMTCT_ARV_OptionB_NewOnART] [int] NULL,
	[PMTCT_ARV_OptionB_AlreadyOnART] [int] NULL,
	[PMTCT_ARV_MaternalAZT] [int] NULL,
	[PMTCT_ARV_Denom_PregnantWomenIdentified] [int] NULL,
	[PMTCT_EID_TestedLT2] [int] NULL,
	[PMTCT_EID_TestedBT2_12] [int] NULL,
	[PMTCT_EID_TestedPositiveLT2] [int] NULL,
	[PMTCT_EID_TestedPositiveBT2_12] [int] NULL,
	[P13D_ProvideANCServices] [bit] NOT NULL,
	[HTC_NGI_Direct] [bit] NOT NULL,
	[HTC_ServiceType] [nvarchar](10) NULL,
	[HTC_TST_MaleLT1] [int] NULL,
	[HTC_TST_MaleBT1_4] [int] NULL,
	[HTC_TST_MaleBT5_9] [int] NULL,
	[HTC_TST_MaleBT10_14] [int] NULL,
	[HTC_TST_MaleBT15_19] [int] NULL,
	[HTC_TST_MaleBT20_24] [int] NULL,
	[HTC_TST_MaleBT25_49] [int] NULL,
	[HTC_TST_MaleGT50] [int] NULL,
	[HTC_TST_FemaleLT1] [int] NULL,
	[HTC_TST_FemaleBT1_4] [int] NULL,
	[HTC_TST_FemaleBT5_9] [int] NULL,
	[HTC_TST_FemaleBT10_14] [int] NULL,
	[HTC_TST_FemaleBT15_19] [int] NULL,
	[HTC_TST_FemaleBT20_24] [int] NULL,
	[HTC_TST_FemaleBT25_49] [int] NULL,
	[HTC_TST_FemaleGT50] [int] NULL,
	[HTC_TST_ByTestResultPositive] [int] NULL,
	[HTC_TST_ByTestResultNegative] [int] NULL,
	[HTC_TST_ByCoupleIndividualPositive] [int] NULL,
	[HTC_TST_ByCoupleIndividualNegative] [int] NULL,
	[HTC_TST_ByCoupleCouplePositive] [int] NULL,
	[HTC_TST_ByCoupleCoupleNegative] [int] NULL,
	[TZ_CARE_FemaleLT1] [int] NULL,
	[TZ_CARE_FemaleBT1_4] [int] NULL,
	[TZ_CARE_FemaleBT5_9] [int] NULL,
	[TZ_CARE_FemaleBT10_14] [int] NULL,
	[TZ_CARE_FemaleBT15_19] [int] NULL,
	[TZ_CARE_FemaleBT20_24] [int] NULL,
	[TZ_CARE_FemaleBT25_49] [int] NULL,
	[TZ_CARE_FemaleGT50] [int] NULL,
	[TZ_CARE_MaleLT1] [int] NULL,
	[TZ_CARE_MaleBT1_4] [int] NULL,
	[TZ_CARE_MaleBT5_9] [int] NULL,
	[TZ_CARE_MaleBT10_14] [int] NULL,
	[TZ_CARE_MaleBT15_19] [int] NULL,
	[TZ_CARE_MaleBT20_24] [int] NULL,
	[TZ_CARE_MaleBT25_49] [int] NULL,
	[TZ_CARE_MaleGT50] [int] NULL,
	[TZ_NUT_FemaleLT1] [int] NULL,
	[TZ_NUT_FemaleBT1_4] [int] NULL,
	[TZ_NUT_FemaleBT5_14] [int] NULL,
	[TZ_NUT_FemaleBT15_17] [int] NULL,
	[TZ_NUT_FemaleGT18] [int] NULL,
	[TZ_NUT_MaleLT1] [int] NULL,
	[TZ_NUT_MaleBT1_4] [int] NULL,
	[TZ_NUT_MaleBT5_14] [int] NULL,
	[TZ_NUT_MaleBT15_17] [int] NULL,
	[TZ_NUT_MaleGT18] [int] NULL,
	[TZ_ECON_FemaleLT1] [int] NULL,
	[TZ_ECON_FemaleBT1_4] [int] NULL,
	[TZ_ECON_FemaleBT5_9] [int] NULL,
	[TZ_ECON_FemaleBT10_14] [int] NULL,
	[TZ_ECON_FemaleBT15_19] [int] NULL,
	[TZ_ECON_FemaleBT20_24] [int] NULL,
	[TZ_ECON_FemaleBT25_49] [int] NULL,
	[TZ_ECON_FemaleBT50_64] [int] NULL,
	[TZ_ECON_FemaleGT65] [int] NULL,
	[TZ_ECON_MaleLT1] [int] NULL,
	[TZ_ECON_MaleBT1_4] [int] NULL,
	[TZ_ECON_MaleBT5_9] [int] NULL,
	[TZ_ECON_MaleBT10_14] [int] NULL,
	[TZ_ECON_MaleBT15_19] [int] NULL,
	[TZ_ECON_MaleBT20_24] [int] NULL,
	[TZ_ECON_MaleBT25_49] [int] NULL,
	[TZ_ECON_MaleBT50_64] [int] NULL,
	[TZ_ECON_MaleGT65] [int] NULL,
	[TX_RET_Num_BreastFeeding] [int] NULL,
	[TX_RET_Denom_BreastFeeding] [int] NULL,
 CONSTRAINT [PK_dbo.CDCTargetsDemo] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[ComparisonType]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ComparisonType]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ComparisonType](
	[ComparisonType] [int] IDENTITY(1,1) NOT NULL,
	[ComparisonSign] [varchar](50) NULL,
 CONSTRAINT [PK_ComparisonType] PRIMARY KEY CLUSTERED 
(
	[ComparisonType] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[DataInputMethod]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[DataInputMethod]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[DataInputMethod](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](255) NOT NULL,
	[Description] [nvarchar](1000) NULL,
 CONSTRAINT [PK_DataInputMethod] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[District]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[District]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[District](
	[DistrictNo] [int] NOT NULL,
	[District] [varchar](50) NOT NULL,
	[RegionNo] [int] NOT NULL,
	[DistrictCode] [nvarchar](50) NULL,
 CONSTRAINT [PK_District] PRIMARY KEY CLUSTERED 
(
	[DistrictNo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[ErrMsgSMS]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ErrMsgSMS]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ErrMsgSMS](
	[ReceivedSMSNo] [int] IDENTITY(1,1) NOT NULL,
	[SenderNum] [varchar](50) NULL,
	[TxtDetails] [varchar](1000) NULL,
	[DateReceived] [datetime] NULL,
	[FacCode] [varchar](50) NULL,
	[Year] [int] NULL,
	[Period] [int] NULL,
	[RepID] [int] NULL,
	[ErrMsg] [varchar](1000) NULL,
	[Deleted] [bit] NULL,
	[KnownReportingErrorId] [int] NULL,
 CONSTRAINT [PK_ErrMsgSMS] PRIMARY KEY CLUSTERED 
(
	[ReceivedSMSNo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[ExcelTemplateCellAssociations]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ExcelTemplateCellAssociations]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ExcelTemplateCellAssociations](
	[CellId_1] [int] NOT NULL,
	[CellId_2] [int] NOT NULL,
	[IsNumeric] [bit] NOT NULL,
 CONSTRAINT [PK_dbo.ExcelTemplateCellAssociations] PRIMARY KEY CLUSTERED 
(
	[CellId_1] ASC,
	[CellId_2] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[ExcelTemplateCellExtras]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ExcelTemplateCellExtras]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ExcelTemplateCellExtras](
	[ExtrasID] [int] IDENTITY(1,1) NOT NULL,
	[Extras] [nvarchar](1000) NOT NULL,
	[CellID] [int] NOT NULL,
 CONSTRAINT [PK_dbo.ExcelTemplateCellExtras] PRIMARY KEY CLUSTERED 
(
	[ExtrasID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[ExcelTemplateCells]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ExcelTemplateCells]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ExcelTemplateCells](
	[CellID] [int] IDENTITY(1,1) NOT NULL,
	[SheetID] [int] NOT NULL,
	[CellRowIndex] [int] NULL,
	[CellColumnIndex] [int] NULL,
	[IndicatorDataSource] [nvarchar](1000) NULL,
	[ColumnHeader] [nvarchar](1000) NULL,
	[RowHeader] [nvarchar](1000) NULL,
	[ColumnHeaderIndex] [int] NOT NULL,
	[RowHeaderIndex] [int] NOT NULL,
	[CellAddress] [nvarchar](50) NULL,
 CONSTRAINT [PK_ExcelTemplateCells] PRIMARY KEY CLUSTERED 
(
	[CellID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[ExcelTemplateReport]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ExcelTemplateReport]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ExcelTemplateReport](
	[TemplateID] [int] IDENTITY(1,1) NOT NULL,
	[TemplateName] [nvarchar](1000) NULL,
	[Description] [nvarchar](1000) NULL,
	[Filename] [nvarchar](1000) NULL,
	[MainTemplate] [bit] NOT NULL,
	[UsedInSAPR] [bit] NOT NULL,
	[UsedInAPR] [bit] NOT NULL,
	[CalculatingMethod] [int] NULL,
 CONSTRAINT [PK_ExcelTemplateReport] PRIMARY KEY CLUSTERED 
(
	[TemplateID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[ExcelTemplateSheets]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ExcelTemplateSheets]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ExcelTemplateSheets](
	[SheetID] [int] IDENTITY(1,1) NOT NULL,
	[TemplateID] [int] NOT NULL,
	[TemplateSheetName] [nvarchar](1000) NULL,
	[OutputSheetName] [nvarchar](1000) NULL,
	[OutputsheetNameTemplate] [nvarchar](1000) NULL,
	[HasRepetitiveRows] [bit] NOT NULL,
	[HasRepetitiveColumns] [bit] NOT NULL,
	[FirstRepetitiveColumnCellIndex] [int] NULL,
	[FirstRepetitiveRowCellIndex] [int] NULL,
	[LastRepetitiveColumnCellIndex] [int] NULL,
	[LastRepetitiveRowCellIndex] [int] NULL,
 CONSTRAINT [PK_ExcelTemplateSheets] PRIMARY KEY CLUSTERED 
(
	[SheetID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[ExpectedReports]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ExpectedReports]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ExpectedReports](
	[FacCode] [varchar](50) NOT NULL,
	[ReportID] [int] NOT NULL,
	[ReportingStartDate] [datetime] NULL,
	[DirectEntry] [bit] NOT NULL,
 CONSTRAINT [PK_ExpectedReports] PRIMARY KEY CLUSTERED 
(
	[FacCode] ASC,
	[ReportID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Facilities]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Facilities]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Facilities](
	[FacCode] [varchar](50) NOT NULL,
	[FacName] [varchar](250) NOT NULL,
	[FacShortName] [varchar](250) NULL,
	[Region] [int] NOT NULL,
	[District] [int] NOT NULL,
	[PMTCT] [bit] NULL,
	[LD] [bit] NULL,
	[PMTCTYear] [int] NULL,
	[PMTCTPeriod] [int] NULL,
	[LDYear] [int] NULL,
	[LDPeriod] [int] NULL,
	[Description] [nvarchar](1000) NULL,
	[Address] [nvarchar](1000) NULL,
	[PrincipalContact] [nvarchar](1000) NULL,
	[Status] [int] NULL,
	[Remarks] [nvarchar](1000) NULL,
	[ANCStartDate] [datetime] NULL,
	[LDStartDate] [datetime] NULL,
	[HEIDStartDate] [datetime] NULL,
	[ANC] [bit] NULL,
	[HEID] [bit] NULL,
	[PMTCTStartDate] [datetime] NULL,
	[Prophylaxis] [bit] NULL,
	[ProphylaxisStartDate] [datetime] NULL,
	[ActiveDate] [datetime] NULL,
	[InactiveDate] [datetime] NULL,
	[Trained] [bit] NULL,
	[FacilityType] [int] NOT NULL,
	[InternalName] [nvarchar](250) NULL,
	[ProvideDBS] [bit] NOT NULL,
	[DBSStartDate] [datetime] NULL,
	[Activated] [bit] NULL,
	[CreateDate] [datetime] NULL,
	[CreatedByUser] [int] NULL,
	[UpdateDate] [datetime] NULL,
	[UpdatedByUser] [int] NULL,
	[SupportingPartnerId] [int] NOT NULL,
	[Region_RegionNo] [int] NULL,
	[Latitude] [decimal](18, 2) NULL,
	[Longitude] [decimal](18, 2) NULL,
	[RegistryId] [nvarchar](10) NULL,
	[ProvideRCH] [bit] NULL,
	[ProvidePMTCT] [bit] NULL,
	[ProvideTestingAndCounseling] [bit] NULL,
 CONSTRAINT [PK_Facilities] PRIMARY KEY CLUSTERED 
(
	[FacCode] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[FacilityType]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[FacilityType]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[FacilityType](
	[TypeId] [int] IDENTITY(1,1) NOT NULL,
	[TypeName] [nvarchar](250) NOT NULL,
	[TypeDescription] [nvarchar](1000) NULL,
 CONSTRAINT [PK_FacilityType] PRIMARY KEY CLUSTERED 
(
	[TypeId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[ImportTables]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ImportTables]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ImportTables](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[TableName] [nvarchar](255) NOT NULL,
	[CreateSQL] [nvarchar](max) NOT NULL,
	[CreationOrder] [int] NOT NULL,
 CONSTRAINT [PK_ImportTables] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[KnownReportingErrors]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[KnownReportingErrors]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[KnownReportingErrors](
	[ErrorCode] [int] NOT NULL,
	[Name] [nvarchar](250) NOT NULL,
	[Description] [nvarchar](1000) NULL,
 CONSTRAINT [PK_dbo.KnownReportingErrors] PRIMARY KEY CLUSTERED 
(
	[ErrorCode] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[Lalola]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Lalola]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Lalola](
	[Region] [nvarchar](255) NULL,
	[District ] [nvarchar](255) NULL,
	[Facility ] [nvarchar](255) NULL,
	[HTC_NGI_Direct] [nvarchar](255) NULL,
	[HTC_ServiceType] [nvarchar](255) NULL,
	[HTC_TST_MaleLT1] [nvarchar](255) NULL,
	[HTC_TST_FemaleLT1] [nvarchar](255) NULL,
	[HTC_TST_MaleBT1_4] [nvarchar](255) NULL,
	[HTC_TST_FemaleBT1_4] [nvarchar](255) NULL,
	[HTC_TST_MaleBT5_9] [nvarchar](255) NULL,
	[HTC_TST_FemaleBT5_9] [nvarchar](255) NULL,
	[HTC_TST_MaleBT10_14] [nvarchar](255) NULL,
	[HTC_TST_FemaleBT10_14] [nvarchar](255) NULL,
	[HTC_TST_MaleBT15_19] [nvarchar](255) NULL,
	[HTC_TST_FemaleBT15_19] [nvarchar](255) NULL,
	[HTC_TST_MaleBT20_24] [nvarchar](255) NULL,
	[HTC_TST_FemaleBT20_24] [nvarchar](255) NULL,
	[HTC_TST_MaleBT25_29] [nvarchar](255) NULL,
	[HTC_TST_FemaleBT25_29] [nvarchar](255) NULL,
	[HTC_TST_MaleGT50] [nvarchar](255) NULL,
	[HTC_TST_FemaleGT50] [nvarchar](255) NULL,
	[HTC_TST_ByTestResultPositive] [nvarchar](255) NULL,
	[HTC_TST_ByTestResultNegative] [nvarchar](255) NULL,
	[HTC_TST_ByCoupleIndividualPositive] [nvarchar](255) NULL,
	[HTC_TST_ByCoupleIndividualNegative] [nvarchar](255) NULL,
	[HTC_TST_ByCoupleCouplePositive] [nvarchar](255) NULL,
	[HTC_TST_ByCoupleCoupleNegative] [nvarchar](255) NULL,
	[TZ_CARE_NGI_Direct] [nvarchar](255) NULL,
	[TZ_CARE_NGI_ServiceType] [nvarchar](255) NULL,
	[C21D_MaleLT15] [float] NULL,
	[C21D_FemaleLT15] [float] NULL,
	[C21D_MaleGT15] [float] NULL,
	[C21D_FemaleGT15] [float] NULL,
	[TZ_CARE_MaleLT1] [nvarchar](255) NULL,
	[TZ_CARE_FemaleLT1] [nvarchar](255) NULL,
	[TZ_CARE_MaleBT1_4] [nvarchar](255) NULL,
	[TZ_CARE_FemaleBT1_4] [nvarchar](255) NULL,
	[TZ_CARE_MaleBT5_9] [nvarchar](255) NULL,
	[TZ_CARE_FemaleBT5_9] [nvarchar](255) NULL,
	[TZ_CARE_MaleBT10_14] [nvarchar](255) NULL,
	[TZ_CARE_FemaleBT10_14] [nvarchar](255) NULL,
	[TZ_CARE_MaleBT15_19] [nvarchar](255) NULL,
	[TZ_CARE_FemaleBT15_19] [nvarchar](255) NULL,
	[TZ_CARE_MaleBT20_24] [nvarchar](255) NULL,
	[TZ_CARE_FemaleBT20_24] [nvarchar](255) NULL,
	[TZ_CARE_MaleBT25_49] [nvarchar](255) NULL,
	[TZ_CARE_FemaleBT25_49] [nvarchar](255) NULL,
	[TZ_CARE_MaleGT50] [nvarchar](255) NULL,
	[TZ_CARE_FemaleGT50] [nvarchar](255) NULL,
	[TZ_NUT_MaleLT1] [nvarchar](255) NULL,
	[TZ_NUT_FemaleLT1] [nvarchar](255) NULL,
	[TZ_NUT_MaleBT1_4] [nvarchar](255) NULL,
	[TZ_NUT_FemaleBT1_4] [nvarchar](255) NULL,
	[TZ_NUT_MaleBT5_14] [nvarchar](255) NULL,
	[TZ_NUT_FemaleBT5_14] [nvarchar](255) NULL,
	[TZ_NUT_MaleBT15_17] [nvarchar](255) NULL,
	[TZ_NUT_FemaleBT15_17] [nvarchar](255) NULL,
	[TZ_NUT_MaleGT18] [nvarchar](255) NULL,
	[TZ_NUT_FemaleGT18] [nvarchar](255) NULL,
	[TZ_ECON_MaleLT1] [nvarchar](255) NULL,
	[TZ_ECON_FemaleLT1] [nvarchar](255) NULL,
	[TZ_ECON_MaleBT1_4] [nvarchar](255) NULL,
	[TZ_ECON_FemaleBT1_4] [nvarchar](255) NULL,
	[TZ_ECON_MaleBT5_9] [nvarchar](255) NULL,
	[TZ_ECON_FemaleBT5_9] [nvarchar](255) NULL,
	[TZ_ECON_MaleBT10_14] [nvarchar](255) NULL,
	[TZ_ECON_FemaleBT10_14] [nvarchar](255) NULL,
	[TZ_ECON_MaleBT15_19] [nvarchar](255) NULL,
	[TZ_ECON_FemaleBT15_19] [nvarchar](255) NULL,
	[TZ_ECON_MaleBT20_24] [nvarchar](255) NULL,
	[TZ_ECON_FemaleBT20_24] [nvarchar](255) NULL,
	[TZ_ECON_MaleBT25_49] [nvarchar](255) NULL,
	[TZ_ECON_FemaleBT25_49] [nvarchar](255) NULL,
	[TZ_ECON_MaleBT50_64] [nvarchar](255) NULL,
	[TZ_ECON_FemaleBT50_64] [nvarchar](255) NULL,
	[TZ_ECON_MaleGT65] [nvarchar](255) NULL,
	[TZ_ECON_FemaleGT65] [nvarchar](255) NULL,
	[FN_THER_ServiceType] [nvarchar](255) NULL,
	[FN_THER_Num] [nvarchar](255) NULL,
	[FN_THER_Denom] [float] NULL,
	[TB_HIV_NGI_Direct] [nvarchar](255) NULL,
	[TB_HIV_ServiceType] [nvarchar](255) NULL,
	[TB_HIV_Num] [float] NULL,
	[TB_HIV_Denom] [float] NULL,
	[TX_NGI_Direct] [nvarchar](255) NULL,
	[TX_NGI_ServiceType] [nvarchar](255) NULL,
	[TX_NEW_MaleLT1] [float] NULL,
	[TX_NEW_FemaleLT1] [float] NULL,
	[TX_NEW_MaleLT15] [float] NULL,
	[TX_NEW_FemaleLT15] [float] NULL,
	[TX_NEW_MaleGT15] [float] NULL,
	[TX_NEW_FemaleGT15] [float] NULL,
	[TX_NEW_PregnantWomen] [float] NULL,
	[TX_CURR_MaleLT1] [float] NULL,
	[TX_CURR_FemaleLT1] [float] NULL,
	[TX_CURR_MaleLT15] [float] NULL,
	[TX_CURR_FemaleLT15] [float] NULL,
	[TX_CURR_MaleGT15] [float] NULL,
	[TX_CURR_FemaleGT15] [float] NULL,
	[TX_RET_Num_0_4] [float] NULL,
	[TX_RET_Num_5_15] [float] NULL,
	[TX_RET_Num_LT15] [float] NULL,
	[TX_RET_Num_PregnantWomen] [float] NULL,
	[TX_RET_Num_BreastFeeding ] [nvarchar](255) NULL,
	[TX_RET_Denom_0_4] [float] NULL,
	[TX_RET_Denom_5_15] [float] NULL,
	[TX_RET_Denom_LT15] [float] NULL,
	[TX_RET_Denom_PregnantWomen] [float] NULL,
	[TX_RET_Denom_BreastFeeding ] [nvarchar](255) NULL,
	[PMTCT_NGI_Direct] [nvarchar](255) NULL,
	[PMTCT_ServiceType] [nvarchar](255) NULL,
	[PMTCT_STAT_TestedPositive] [nvarchar](255) NULL,
	[PMTCT_STAT_TestedNegative] [nvarchar](255) NULL,
	[PMTCT_KnownPositive] [nvarchar](255) NULL,
	[PMTCT_NewClients] [nvarchar](255) NULL,
	[PMTCT_ARV_OptionB_NewOnART] [nvarchar](255) NULL,
	[PMTCT_ARV_OptionB_AlreadyOnART] [nvarchar](255) NULL,
	[PMTCT_ARV_MaternalAZT] [nvarchar](255) NULL,
	[PMTCT_ARV_Denom_PregnantWomenIdentified] [nvarchar](255) NULL,
	[PMTCT_EID_TestedLT2] [nvarchar](255) NULL,
	[PMTCT_EID_TestedBT2_12] [nvarchar](255) NULL,
	[PMTCT_EID_TestedPositiveLT2] [nvarchar](255) NULL,
	[PMTCT_EID_TestedPositiveBT2_12] [nvarchar](255) NULL,
	[P13D_ProvideANCServices] [nvarchar](255) NULL
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[Languages]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Languages]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Languages](
	[LangID] [int] IDENTITY(1,1) NOT NULL,
	[Language] [nvarchar](200) NULL,
 CONSTRAINT [PK_Languages] PRIMARY KEY CLUSTERED 
(
	[LangID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[LDForm_EmOC]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[LDForm_EmOC]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[LDForm_EmOC](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[C_7a] [int] NOT NULL,
	[C_7b] [int] NOT NULL,
	[C_7c] [int] NOT NULL,
	[C_7d] [int] NOT NULL,
	[C_7e] [int] NOT NULL,
	[C_7f] [int] NOT NULL,
	[MetadataId] [int] NOT NULL,
	[FacilityCode] [varchar](50) NULL,
	[ReportDate] [datetime] NOT NULL,
	[LessThan20] [bit] NOT NULL,
	[Comments] [nvarchar](1000) NULL,
	[Year]  AS (datepart(year,[ReportDate])),
	[Month]  AS (datepart(month,[ReportDate])),
 CONSTRAINT [PK_dbo.LDForm_EmOC] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[LDForm_MatatizoBaadaYaKujifungua]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[LDForm_MatatizoBaadaYaKujifungua]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[LDForm_MatatizoBaadaYaKujifungua](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[C_6a] [int] NOT NULL,
	[C_6b] [int] NOT NULL,
	[C_6c] [int] NOT NULL,
	[C_6d] [int] NOT NULL,
	[C_6e] [int] NOT NULL,
	[C_6f] [int] NOT NULL,
	[C_6g] [int] NOT NULL,
	[C_6h] [int] NOT NULL,
	[C_6i] [int] NOT NULL,
	[MetadataId] [int] NOT NULL,
	[FacilityCode] [varchar](50) NULL,
	[ReportDate] [datetime] NOT NULL,
	[LessThan20] [bit] NOT NULL,
	[Comments] [nvarchar](1000) NULL,
	[Year]  AS (datepart(year,[ReportDate])),
	[Month]  AS (datepart(month,[ReportDate])),
 CONSTRAINT [PK_dbo.LDForm_MatatizoBaadaYaKujifungua] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[LDForm_MatatizoKablaYaKujifungua]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[LDForm_MatatizoKablaYaKujifungua]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[LDForm_MatatizoKablaYaKujifungua](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[C_4a] [int] NOT NULL,
	[C_4b] [int] NOT NULL,
	[C_4c] [int] NOT NULL,
	[C_4d] [int] NOT NULL,
	[C_4e] [int] NOT NULL,
	[C_4f] [int] NOT NULL,
	[C_4g] [int] NOT NULL,
	[C_4h] [int] NOT NULL,
	[C_4i] [int] NOT NULL,
	[MetadataId] [int] NOT NULL,
	[FacilityCode] [varchar](50) NULL,
	[ReportDate] [datetime] NOT NULL,
	[LessThan20] [bit] NOT NULL,
	[Comments] [nvarchar](1000) NULL,
	[Year]  AS (datepart(year,[ReportDate])),
	[Month]  AS (datepart(month,[ReportDate])),
	[C_4j] [int] NOT NULL,
	[C_4k] [int] NOT NULL,
 CONSTRAINT [PK_dbo.LDForm_MatatizoKablaYaKujifungua] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[LDForm_NjiaYaKujifungua]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[LDForm_NjiaYaKujifungua]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[LDForm_NjiaYaKujifungua](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[C_3a] [int] NOT NULL,
	[C_3b] [int] NOT NULL,
	[C_3c] [int] NOT NULL,
	[C_3d] [int] NOT NULL,
	[C_3e] [int] NOT NULL,
	[C_3f] [int] NOT NULL,
	[C_3g] [int] NOT NULL,
	[MetadataId] [int] NOT NULL,
	[FacilityCode] [varchar](50) NULL,
	[ReportDate] [datetime] NOT NULL,
	[LessThan20] [bit] NOT NULL,
	[Comments] [nvarchar](1000) NULL,
	[Year]  AS (datepart(year,[ReportDate])),
	[Month]  AS (datepart(month,[ReportDate])),
 CONSTRAINT [PK_dbo.LDForm_NjiaYaKujifungua] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[LDForm_PMTCT]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[LDForm_PMTCT]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[LDForm_PMTCT](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[C_8a] [int] NOT NULL,
	[C_8b] [int] NOT NULL,
	[C_8c] [int] NOT NULL,
	[C_8d] [int] NOT NULL,
	[C_8e] [int] NOT NULL,
	[C_8f] [int] NOT NULL,
	[C_8g] [int] NOT NULL,
	[C_8h] [int] NOT NULL,
	[C_8i] [int] NOT NULL,
	[C_8j] [int] NOT NULL,
	[C_8k] [int] NOT NULL,
	[C_8l] [int] NOT NULL,
	[C_8m] [int] NOT NULL,
	[C_8n] [int] NOT NULL,
	[MetadataId] [int] NOT NULL,
	[FacilityCode] [varchar](50) NULL,
	[ReportDate] [datetime] NOT NULL,
	[LessThan20] [bit] NOT NULL,
	[Comments] [nvarchar](1000) NULL,
	[Year]  AS (datepart(year,[ReportDate])),
	[Month]  AS (datepart(month,[ReportDate])),
 CONSTRAINT [PK_dbo.LDForm_PMTCT] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[LDForm_TaarifaYaWaliojifungua]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[LDForm_TaarifaYaWaliojifungua]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[LDForm_TaarifaYaWaliojifungua](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[C_2a] [int] NOT NULL,
	[C_2b] [int] NOT NULL,
	[C_2c] [int] NOT NULL,
	[C_2d] [int] NOT NULL,
	[C_2e] [int] NOT NULL,
	[C_2f] [int] NOT NULL,
	[C_2g] [int] NOT NULL,
	[MetadataId] [int] NOT NULL,
	[FacilityCode] [varchar](50) NULL,
	[ReportDate] [datetime] NOT NULL,
	[LessThan20] [bit] NOT NULL,
	[Comments] [nvarchar](1000) NULL,
	[Year]  AS (datepart(year,[ReportDate])),
	[Month]  AS (datepart(month,[ReportDate])),
 CONSTRAINT [PK_dbo.LDForm_TaarifaYaWaliojifungua] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[LDForm_WatotoWaliosaidiwaKupumua]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[LDForm_WatotoWaliosaidiwaKupumua]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[LDForm_WatotoWaliosaidiwaKupumua](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[C_11a] [int] NOT NULL,
	[C_11b] [int] NOT NULL,
	[C_11c] [int] NOT NULL,
	[MetadataId] [int] NOT NULL,
	[FacilityCode] [varchar](50) NULL,
	[ReportDate] [datetime] NOT NULL,
	[LessThan20] [bit] NOT NULL,
	[Comments] [nvarchar](1000) NULL,
	[Year]  AS (datepart(year,[ReportDate])),
	[Month]  AS (datepart(month,[ReportDate])),
 CONSTRAINT [PK_dbo.LDForm_WatotoWaliosaidiwaKupumua] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[LDForm_WatotoWaliozaliwaMapacha]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[LDForm_WatotoWaliozaliwaMapacha]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[LDForm_WatotoWaliozaliwaMapacha](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[MetadataId] [int] NOT NULL,
	[FacilityCode] [varchar](50) NULL,
	[ReportDate] [datetime] NOT NULL,
	[LessThan20] [bit] NOT NULL,
	[Comments] [nvarchar](1000) NULL,
	[C_10a] [int] NOT NULL,
	[C_10b] [int] NOT NULL,
	[C_10c] [int] NOT NULL,
	[C_10d] [int] NOT NULL,
	[C_10e] [int] NOT NULL,
	[C_10f] [int] NOT NULL,
	[C_10g] [int] NOT NULL,
	[C_10h] [int] NOT NULL,
	[Year]  AS (datepart(year,[ReportDate])),
	[Month]  AS (datepart(month,[ReportDate])),
	[C_10i] [int] NOT NULL,
 CONSTRAINT [PK_dbo.LDForm_WatotoWaliozaliwaMapacha] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[LDForm_WatotoWaliozaliwaMmoja]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[LDForm_WatotoWaliozaliwaMmoja]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[LDForm_WatotoWaliozaliwaMmoja](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[C_9a] [int] NOT NULL,
	[C_9b] [int] NOT NULL,
	[C_9c] [int] NOT NULL,
	[C_9d] [int] NOT NULL,
	[C_9e] [int] NOT NULL,
	[C_9f] [int] NOT NULL,
	[C_9g] [int] NOT NULL,
	[C_9h] [int] NOT NULL,
	[C_9i] [int] NOT NULL,
	[MetadataId] [int] NOT NULL,
	[FacilityCode] [varchar](50) NULL,
	[ReportDate] [datetime] NOT NULL,
	[LessThan20] [bit] NOT NULL,
	[Comments] [nvarchar](1000) NULL,
	[Year]  AS (datepart(year,[ReportDate])),
	[Month]  AS (datepart(month,[ReportDate])),
 CONSTRAINT [PK_dbo.LDForm_WatotoWaliozaliwaMmoja] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[LDForms]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[LDForms]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[LDForms](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[C_1] [int] NULL,
	[C_5] [int] NULL,
	[C_12] [int] NULL,
	[C_13] [int] NULL,
	[C_14] [int] NULL,
	[TaarifaYaWaliojifungua_2id] [int] NULL,
	[NjiaYaKujifungua_3id] [int] NULL,
	[MatatizoKablaYaKujifungua_4id] [int] NULL,
	[MatatizoBaadaYaKujifungua_6id] [int] NULL,
	[EmOC_7id] [int] NULL,
	[PMTCT_8id] [int] NULL,
	[WatotoWaliozaliwaMmoja_9id] [int] NULL,
	[WatotoWaliozaliwaMapacha_10id] [int] NULL,
	[WatotoWaliosaidiwaKupumua_11id] [int] NULL,
	[MetadataId] [int] NOT NULL,
	[FacilityCode] [varchar](50) NULL,
	[ReportDate] [datetime] NOT NULL,
	[LessThan20] [bit] NOT NULL,
	[Comments] [nvarchar](1000) NULL,
	[Year]  AS (datepart(year,[ReportDate])),
	[Month]  AS (datepart(month,[ReportDate])),
 CONSTRAINT [PK_dbo.LDForms] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[MARA$]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MARA$]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[MARA$](
	[Facilities] [nvarchar](255) NULL,
	[DISTRICT] [nvarchar](255) NULL
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[MergingReports]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MergingReports]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[MergingReports](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[MergeId] [int] NOT NULL,
	[DestinationReportId] [int] NOT NULL,
	[SourceReportId] [int] NOT NULL,
 CONSTRAINT [PK_MergingReports] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[MessagingLogs]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MessagingLogs]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[MessagingLogs](
	[MessagingLogId] [int] IDENTITY(1,1) NOT NULL,
	[PhoneNumber] [nvarchar](50) NOT NULL,
	[MessageBody] [nvarchar](1000) NOT NULL,
	[DateSendReceived] [datetime] NOT NULL,
	[IsMessageSentToUser] [bit] NOT NULL,
 CONSTRAINT [PK_dbo.MessagingLogs] PRIMARY KEY CLUSTERED 
(
	[MessagingLogId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[MobileContryCode]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MobileContryCode]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[MobileContryCode](
	[MCC] [nvarchar](3) NOT NULL,
	[ISOCode] [nvarchar](2) NULL,
	[Country] [nvarchar](250) NULL,
 CONSTRAINT [PK_MobileContryCode] PRIMARY KEY CLUSTERED 
(
	[MCC] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[MobilePhoneOperators]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MobilePhoneOperators]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[MobilePhoneOperators](
	[MCC] [nvarchar](3) NOT NULL,
	[MNC] [nvarchar](3) NOT NULL,
	[Brand] [nvarchar](100) NULL,
	[Operator] [nvarchar](250) NULL,
	[Status] [nvarchar](50) NULL,
	[Bands_MHz] [nvarchar](250) NULL,
	[Notes] [nvarchar](1000) NULL,
 CONSTRAINT [PK_MobilePhoneOperators] PRIMARY KEY CLUSTERED 
(
	[MCC] ASC,
	[MNC] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[ModemAssociatedCellNumbers]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ModemAssociatedCellNumbers]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ModemAssociatedCellNumbers](
	[ModemNumberID] [int] IDENTITY(1,1) NOT NULL,
	[ModemSettingNo] [int] NOT NULL,
	[AssociatedCellNum] [varchar](50) NULL,
 CONSTRAINT [PK_ModemAssociatedCellNumbers] PRIMARY KEY CLUSTERED 
(
	[ModemNumberID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[ModemSettings]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ModemSettings]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ModemSettings](
	[ModemSettingNo] [int] IDENTITY(1,1) NOT NULL,
	[ModemName] [varchar](50) NULL,
	[PortName] [varchar](50) NULL,
	[BaudRate] [int] NULL,
	[DataBits] [int] NULL,
	[StopBits] [int] NULL,
	[ParityBits] [varchar](50) NULL,
	[ReadTimeout] [int] NULL,
	[WriteTimeout] [int] NULL,
 CONSTRAINT [PK_ModemSettings] PRIMARY KEY CLUSTERED 
(
	[ModemSettingNo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[MTUHA_Reports]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MTUHA_Reports]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[MTUHA_Reports](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](255) NOT NULL,
	[ReleaseDate] [datetime] NULL,
	[Description] [nvarchar](1000) NULL,
 CONSTRAINT [PK_MTUHAReports] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[MTUHA_ReportSectionDetails]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MTUHA_ReportSectionDetails]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[MTUHA_ReportSectionDetails](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[SectionId] [int] NOT NULL,
	[ShortCode] [nvarchar](10) NOT NULL,
	[Name] [nvarchar](255) NOT NULL,
	[Description] [nvarchar](1000) NULL,
 CONSTRAINT [PK_MTUHA_ReportSectionDetails] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[MTUHA_ReportSections]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MTUHA_ReportSections]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[MTUHA_ReportSections](
	[SectionId] [int] IDENTITY(1,1) NOT NULL,
	[MTUHAReportId] [int] NOT NULL,
	[SectionNumber] [int] NOT NULL,
	[Name] [nvarchar](255) NOT NULL,
 CONSTRAINT [PK_MTUHA_ReportSection] PRIMARY KEY CLUSTERED 
(
	[SectionId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[OfflineReportIndicators]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OfflineReportIndicators]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[OfflineReportIndicators](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[ShortCode] [nvarchar](max) NULL,
	[Name] [nvarchar](max) NULL,
	[Value] [nvarchar](max) NULL,
	[OfflineReport_Id] [int] NULL,
 CONSTRAINT [PK_dbo.OfflineReportIndicators] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[OfflineReports]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OfflineReports]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[OfflineReports](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[FacilityCode] [varchar](50) NULL,
	[FacilityName] [nvarchar](max) NULL,
	[ReportYear] [int] NOT NULL,
	[ReportMonth] [int] NOT NULL,
	[DateSavedOffline] [datetime] NOT NULL,
	[ReportId] [int] NOT NULL,
	[ReportName] [nvarchar](max) NULL,
	[ReportMessage] [nvarchar](max) NULL,
	[CreatedByUserId] [int] NOT NULL,
	[CreatedByUserName] [nvarchar](max) NULL,
	[ReportComments] [nvarchar](max) NULL,
 CONSTRAINT [PK_dbo.OfflineReports] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[OptionBPlusFacilities]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OptionBPlusFacilities]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[OptionBPlusFacilities](
	[FacilityCode] [varchar](50) NOT NULL,
	[DateStarted] [datetime] NOT NULL,
	[DateTrained] [datetime] NULL,
	[HasCTC] [bit] NOT NULL,
	[CTCStartDate] [datetime] NULL,
	[UpdatedByUserId] [int] NULL,
	[UpdateDate] [datetime] NULL,
 CONSTRAINT [PK_dbo.OptionBPlusFacilities] PRIMARY KEY CLUSTERED 
(
	[FacilityCode] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[OptionBPlusFacilities[Dump]]]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OptionBPlusFacilities[Dump]]]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[OptionBPlusFacilities[Dump]]](
	[Facilities] [nvarchar](255) NULL,
	[DISTRICT] [nvarchar](255) NULL,
	[HasCTC] [bit] NOT NULL,
	[CTCStartDate] [datetime] NULL
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[OtherSystems]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OtherSystems]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[OtherSystems](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](255) NOT NULL,
	[Description] [nvarchar](max) NULL,
	[ProvidesFacilityUniqueIdentifier] [bit] NOT NULL,
 CONSTRAINT [PK_OtherSystems] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[OtherSystemsDistrictDetails]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OtherSystemsDistrictDetails]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[OtherSystemsDistrictDetails](
	[SystemId] [int] NOT NULL,
	[InternalDistrictId] [int] NOT NULL,
	[DistrictCode] [nvarchar](50) NOT NULL,
	[DistrictName] [nvarchar](255) NOT NULL,
 CONSTRAINT [PK_dbo.OtherSystemsDistrictDetails] PRIMARY KEY CLUSTERED 
(
	[SystemId] ASC,
	[InternalDistrictId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[OtherSystemsFacilityDetails]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OtherSystemsFacilityDetails]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[OtherSystemsFacilityDetails](
	[SystemId] [int] NOT NULL,
	[InternalFacilityCode] [varchar](50) NOT NULL,
	[FacilityCode] [nvarchar](50) NOT NULL,
	[FacilityName] [nvarchar](255) NOT NULL,
	[DistrictName] [nvarchar](255) NOT NULL,
	[RegionName] [nvarchar](255) NOT NULL,
	[HTC_ServiceType] [nvarchar](10) NULL,
	[Care_ServiceType] [nvarchar](10) NULL,
	[FN_ServiceType] [nvarchar](10) NULL,
	[TB_HIV_ServiceType] [nvarchar](10) NULL,
	[TX_ServiceType] [nvarchar](10) NULL,
	[PMTCT_ServiceType] [nvarchar](10) NULL,
	[HRH_ServiceType] [nvarchar](10) NULL,
	[LAB_ServiceType] [nvarchar](10) NULL,
	[VMMC_ServiceType] [nvarchar](10) NULL,
	[GPY_ServiceType] [nvarchar](10) NULL,
	[KP_ServiceType] [nvarchar](10) NULL,
	[OVC_ServiceType] [nvarchar](10) NULL,
	[FPINT_ServiceType] [nvarchar](10) NULL,
 CONSTRAINT [PK_OtherSystemsFacilityDetails] PRIMARY KEY CLUSTERED 
(
	[SystemId] ASC,
	[InternalFacilityCode] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[OtherSystemsRegionDetails]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OtherSystemsRegionDetails]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[OtherSystemsRegionDetails](
	[SystemId] [int] NOT NULL,
	[InternalRegionId] [int] NOT NULL,
	[RegionCode] [nvarchar](50) NOT NULL,
	[RegionName] [nvarchar](255) NOT NULL,
 CONSTRAINT [PK_dbo.OtherSystemsRegionDetails] PRIMARY KEY CLUSTERED 
(
	[SystemId] ASC,
	[InternalRegionId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[OtherSystemUserNumbers]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OtherSystemUserNumbers]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[OtherSystemUserNumbers](
	[PhoneNumber] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_dbo.OtherSystemUserNumbers] PRIMARY KEY CLUSTERED 
(
	[PhoneNumber] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[PresetCharts]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PresetCharts]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PresetCharts](
	[ChartID] [int] IDENTITY(1,1) NOT NULL,
	[ChartName] [nvarchar](255) NOT NULL,
 CONSTRAINT [PK_PresetReports] PRIMARY KEY CLUSTERED 
(
	[ChartID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[PresetChartsIndicators]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PresetChartsIndicators]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PresetChartsIndicators](
	[IndicatorID] [int] IDENTITY(1,1) NOT NULL,
	[ChartID] [int] NOT NULL,
	[CompositeIndicator] [bit] NOT NULL,
	[IndicatorName] [nvarchar](255) NOT NULL,
	[IndicatorDefinition] [nvarchar](255) NOT NULL,
 CONSTRAINT [PK_PresetReportsIndicators] PRIMARY KEY CLUSTERED 
(
	[IndicatorID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[Queries]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Queries]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Queries](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](1000) NOT NULL,
	[InternalName] [nvarchar](1000) NULL,
	[Description] [nvarchar](1000) NULL,
	[Definition] [nvarchar](max) NOT NULL,
	[QueryTypeId] [int] NULL,
	[Deleted] [bit] NOT NULL,
	[CreateDate] [datetime] NOT NULL,
	[CreatedByUserId] [int] NOT NULL,
	[UpdateDate] [smalldatetime] NULL,
	[UpdatedByUserId] [int] NULL,
	[DeleteDate] [smalldatetime] NULL,
	[DeletedByUserId] [int] NULL,
	[CreateTable] [bit] NOT NULL,
	[User_ID] [int] NULL,
	[More] [nvarchar](1000) NULL,
 CONSTRAINT [PK_Queries] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[QueryCategories]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[QueryCategories]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[QueryCategories](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](1000) NULL,
	[Description] [nvarchar](1000) NULL,
	[Deleted] [bit] NULL,
	[CreateDate] [smalldatetime] NULL,
	[CreatedByUserId] [int] NULL,
	[UpdateDate] [smalldatetime] NULL,
	[UpdatedByUserId] [int] NULL,
	[DeleteDate] [smalldatetime] NULL,
	[DeletedByUserId] [int] NULL,
	[User_ID] [int] NULL,
 CONSTRAINT [PK_QueryCategories] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[QueryCategoryQueries]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[QueryCategoryQueries]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[QueryCategoryQueries](
	[QueryCategory_Id] [int] NOT NULL,
	[Query_Id] [int] NOT NULL,
 CONSTRAINT [PK_dbo.QueryCategoryQueries] PRIMARY KEY CLUSTERED 
(
	[QueryCategory_Id] ASC,
	[Query_Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[QueryParameters]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[QueryParameters]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[QueryParameters](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](200) NOT NULL,
	[Description] [nvarchar](1000) NOT NULL,
	[ValidationExpression] [nvarchar](1000) NOT NULL,
	[DataTypeName] [nvarchar](1000) NOT NULL,
	[QueryId] [int] NOT NULL,
 CONSTRAINT [PK_dbo.QueryParameters] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[QueryTypes]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[QueryTypes]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[QueryTypes](
	[QueryTypeId] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](1000) NULL,
	[Description] [nvarchar](1000) NULL,
 CONSTRAINT [PK_QueryType] PRIMARY KEY CLUSTERED 
(
	[QueryTypeId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[ReceivedSMS]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ReceivedSMS]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ReceivedSMS](
	[ReceivedSMSNo] [int] IDENTITY(1,1) NOT NULL,
	[SenderNum] [nvarchar](100) NOT NULL,
	[TxtDetails] [nvarchar](999) NOT NULL,
	[DateReceived] [datetime] NULL,
	[Processed] [bit] NULL,
	[FacCode] [varchar](50) NOT NULL,
	[Year] [int] NULL,
	[Period] [int] NULL,
	[RepID] [int] NULL,
	[ReportDate] [datetime] NULL,
	[Comments] [nvarchar](1000) NULL,
 CONSTRAINT [PK_ReceivedSMS] PRIMARY KEY CLUSTERED 
(
	[ReceivedSMSNo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Region]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Region]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Region](
	[RegionNo] [int] NOT NULL,
	[RegionName] [varchar](50) NOT NULL,
	[RegionCode] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_Region] PRIMARY KEY CLUSTERED 
(
	[RegionNo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Report]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Report]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Report](
	[RepID] [int] IDENTITY(1,1) NOT NULL,
	[ReportName] [nvarchar](250) NULL,
	[RepVersion] [nvarchar](50) NULL,
	[RepTemplate] [nvarchar](200) NULL,
	[Description] [nvarchar](1000) NULL,
	[Comments] [nvarchar](1000) NULL,
	[UsedAsView] [bit] NOT NULL,
 CONSTRAINT [PK_Report] PRIMARY KEY CLUSTERED 
(
	[RepID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[ReportBusinessRules]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ReportBusinessRules]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ReportBusinessRules](
	[BRNo] [int] IDENTITY(1,1) NOT NULL,
	[RepID] [int] NULL,
	[MeasurePosNo] [int] NOT NULL,
	[RuleDescription] [varchar](1000) NOT NULL,
	[Action] [int] NOT NULL,
	[ComparedToOrderPos] [varchar](50) NULL,
	[ComparisonType] [int] NULL,
	[Multicomparison] [bit] NULL,
 CONSTRAINT [PK_ReportBusinessRules] PRIMARY KEY CLUSTERED 
(
	[BRNo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[ReportChartIndicators]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ReportChartIndicators]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ReportChartIndicators](
	[ReportIndicatorID] [int] IDENTITY(1,1) NOT NULL,
	[ReportID] [int] NOT NULL,
	[ReportDataPosition] [int] NOT NULL,
	[ReportDataPositionDescription] [nvarchar](255) NOT NULL,
 CONSTRAINT [PK_ReportChartIndicators] PRIMARY KEY CLUSTERED 
(
	[ReportIndicatorID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[ReportData]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ReportData]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ReportData](
	[SID] [int] IDENTITY(1,1) NOT NULL,
	[ReceivedSMSNo] [int] NULL,
	[RepID] [int] NULL,
	[DataPosition] [int] NULL,
	[Data] [varchar](50) NULL,
 CONSTRAINT [PK_ReportData] PRIMARY KEY CLUSTERED 
(
	[SID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[ReportDataLocations]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ReportDataLocations]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ReportDataLocations](
	[MeasureNo] [int] IDENTITY(1,1) NOT NULL,
	[RepID] [int] NOT NULL,
	[DataDescription] [varchar](200) NOT NULL,
	[DataPosition] [int] NOT NULL,
	[DataType] [varchar](50) NOT NULL,
	[ShortCode] [varchar](50) NULL,
 CONSTRAINT [PK_ReportDataLocations] PRIMARY KEY CLUSTERED 
(
	[MeasureNo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[ReportDataMerging]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ReportDataMerging]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ReportDataMerging](
	[DataMergeId] [int] IDENTITY(1,1) NOT NULL,
	[MergeId] [int] NOT NULL,
	[DestinationIndicator] [nvarchar](250) NOT NULL,
	[SourceIndicator] [nvarchar](250) NOT NULL,
	[Comments] [nvarchar](1000) NULL,
 CONSTRAINT [PK_ReportDataMerging] PRIMARY KEY CLUSTERED 
(
	[DataMergeId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[ReportDataSetElementsLinks]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ReportDataSetElementsLinks]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ReportDataSetElementsLinks](
	[ReportDataSetLinkId] [int] NOT NULL,
	[ReportIndicatorId] [int] NOT NULL,
	[DataElementId] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_dbo.ReportDataSetElementsLinks] PRIMARY KEY CLUSTERED 
(
	[ReportDataSetLinkId] ASC,
	[ReportIndicatorId] ASC,
	[DataElementId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[ReportDataSetLinks]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ReportDataSetLinks]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ReportDataSetLinks](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[ReportId] [int] NOT NULL,
	[DataSetId] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_dbo.ReportDataSetLinks] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[ReportMerge]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ReportMerge]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ReportMerge](
	[MergeId] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](250) NOT NULL,
	[Description] [nvarchar](1000) NULL,
 CONSTRAINT [PK_ReportMerge] PRIMARY KEY CLUSTERED 
(
	[MergeId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[SampleTable]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SampleTable]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SampleTable](
	[Measures] [int] NULL,
	[Count] [int] NULL,
	[Facility] [int] NULL
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[SendSMSQueue]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SendSMSQueue]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SendSMSQueue](
	[SMSSID] [int] IDENTITY(1,1) NOT NULL,
	[SenderNum] [varchar](50) NULL,
	[TxtDetails] [varchar](1000) NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[SendSMSQueue_Backup]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SendSMSQueue_Backup]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SendSMSQueue_Backup](
	[SMSSID] [int] NOT NULL,
	[SenderNum] [varchar](50) NULL,
	[TxtDetails] [varchar](1000) NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[SMSLog]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SMSLog]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SMSLog](
	[SMSIDNo] [int] IDENTITY(1,1) NOT NULL,
	[SMSType] [bit] NULL,
	[CellNum] [varchar](50) NULL,
	[Message] [varchar](1000) NULL,
	[Date] [datetime] NULL,
	[ReceivedSMSNo] [varchar](50) NULL,
	[Processed] [bit] NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[SMSReminders]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SMSReminders]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SMSReminders](
	[SMSRID] [int] IDENTITY(1,1) NOT NULL,
	[SMSDate] [date] NULL,
	[SMSTime] [time](7) NULL,
 CONSTRAINT [PK_SMSReminders] PRIMARY KEY CLUSTERED 
(
	[SMSRID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[SMSReminderTracker]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SMSReminderTracker]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SMSReminderTracker](
	[FacCode] [varchar](50) NOT NULL,
	[Year] [int] NOT NULL,
	[Period] [int] NOT NULL,
	[ReportID] [int] NOT NULL,
 CONSTRAINT [PK_SMSReminderTracker] PRIMARY KEY CLUSTERED 
(
	[FacCode] ASC,
	[Year] ASC,
	[Period] ASC,
	[ReportID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[StockStatus]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[StockStatus]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[StockStatus](
	[FacCode] [varchar](50) NOT NULL,
	[RequiredDetermine] [int] NOT NULL,
	[RequiredUnigold] [int] NOT NULL,
	[RequiredDBS] [int] NOT NULL,
	[AvailableDetermine] [int] NULL,
	[AvailableUnigold] [int] NULL,
	[AvailableDBS] [int] NULL,
	[DateReportReceived] [datetime] NULL,
	[ReportDate] [datetime] NOT NULL,
	[ReportYear] [int] NOT NULL,
	[ReportMonth] [int] NOT NULL,
 CONSTRAINT [PK_dbo.StockStatus] PRIMARY KEY CLUSTERED 
(
	[FacCode] ASC,
	[ReportDate] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[SupportingPartners]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SupportingPartners]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SupportingPartners](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](255) NOT NULL,
	[Description] [nvarchar](1000) NULL,
 CONSTRAINT [PK_SupportingPartners] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[SysSettings]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SysSettings]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SysSettings](
	[SettingName] [varchar](500) NOT NULL,
	[SettingValue] [varchar](1000) NOT NULL,
 CONSTRAINT [PK_SysSettings] PRIMARY KEY CLUSTERED 
(
	[SettingName] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[TestingAndCounselingDatas]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TestingAndCounselingDatas]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[TestingAndCounselingDatas](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[FacilityCode] [varchar](50) NOT NULL,
	[TimeframeId] [int] NOT NULL,
	[CounselingAndTestingId] [int] NOT NULL,
	[TC01_MaleLT15] [int] NOT NULL,
	[TC01_MaleGT15] [int] NOT NULL,
	[TC01_FemaleLT15] [int] NOT NULL,
	[TC01_FemaleGT15] [int] NOT NULL,
	[TC02_MaleLT15] [int] NOT NULL,
	[TC02_MaleGT15] [int] NOT NULL,
	[TC02_FemaleLT15] [int] NOT NULL,
	[TC02_FemaleGT15] [int] NOT NULL,
	[TC03_MaleLT15] [int] NOT NULL,
	[TC03_MaleGT15] [int] NOT NULL,
	[TC03_FemaleLT15] [int] NOT NULL,
	[TC03_FemaleGT15] [int] NOT NULL,
	[TC04_MaleLT15] [int] NOT NULL,
	[TC04_MaleGT15] [int] NOT NULL,
	[TC04_FemaleLT15] [int] NOT NULL,
	[TC04_FemaleGT15] [int] NOT NULL,
	[TC05_MaleLT15] [int] NOT NULL,
	[TC05_MaleGT15] [int] NOT NULL,
	[TC05_FemaleLT15] [int] NOT NULL,
	[TC05_FemaleGT15] [int] NOT NULL,
	[TC06_MaleLT15] [int] NOT NULL,
	[TC06_MaleGT15] [int] NOT NULL,
	[TC06_FemaleLT15] [int] NOT NULL,
	[TC06_FemaleGT15] [int] NOT NULL,
	[TC07_MaleLT15] [int] NOT NULL,
	[TC07_MaleGT15] [int] NOT NULL,
	[TC07_FemaleLT15] [int] NOT NULL,
	[TC07_FemaleGT15] [int] NOT NULL,
	[TC08_MaleLT15] [int] NOT NULL,
	[TC08_MaleGT15] [int] NOT NULL,
	[TC08_FemaleLT15] [int] NOT NULL,
	[TC08_FemaleGT15] [int] NOT NULL,
	[TC09_MaleLT15] [int] NOT NULL,
	[TC09_MaleGT15] [int] NOT NULL,
	[TC09_FemaleLT15] [int] NOT NULL,
	[TC09_FemaleGT15] [int] NOT NULL,
	[TC10_MaleLT15] [int] NOT NULL,
	[TC10_MaleGT15] [int] NOT NULL,
	[TC10_FemaleLT15] [int] NOT NULL,
	[TC10_FemaleGT15] [int] NOT NULL,
	[TC11_MaleLT15] [int] NOT NULL,
	[TC11_MaleGT15] [int] NOT NULL,
	[TC11_FemaleLT15] [int] NOT NULL,
	[TC11_FemaleGT15] [int] NOT NULL,
	[TC12_MaleLT15] [int] NOT NULL,
	[TC12_MaleGT15] [int] NOT NULL,
	[TC12_FemaleLT15] [int] NOT NULL,
	[TC12_FemaleGT15] [int] NOT NULL,
	[UserId] [int] NULL,
	[DateCreated] [datetime] NULL,
 CONSTRAINT [PK_dbo.TestingAndCounselingDatas] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[TestingAndCounselings]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TestingAndCounselings]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[TestingAndCounselings](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](10) NOT NULL,
	[Description] [nvarchar](1000) NOT NULL,
 CONSTRAINT [PK_dbo.TestingAndCounselings] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[Timeframes]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Timeframes]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Timeframes](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](7) NULL,
	[Description] [nvarchar](1000) NULL,
	[StartTime] [datetime] NOT NULL,
	[EndTime] [datetime] NOT NULL,
 CONSTRAINT [PK_dbo.Timeframes] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[Translations]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Translations]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Translations](
	[TransID] [int] IDENTITY(1,1) NOT NULL,
	[LangID] [int] NOT NULL,
	[LabelNo] [int] NOT NULL,
	[LText] [nvarchar](1000) NOT NULL,
 CONSTRAINT [PK_Translations] PRIMARY KEY CLUSTERED 
(
	[TransID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[TripReportDistricts]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TripReportDistricts]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[TripReportDistricts](
	[DistrictId] [int] NOT NULL,
	[TripReportId] [int] NOT NULL,
 CONSTRAINT [PK_dbo.TripReportDistricts] PRIMARY KEY CLUSTERED 
(
	[DistrictId] ASC,
	[TripReportId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[TripReportMonths]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TripReportMonths]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[TripReportMonths](
	[TripReportId] [int] NOT NULL,
	[ReportMonth] [nvarchar](128) NOT NULL,
 CONSTRAINT [PK_dbo.TripReportMonths] PRIMARY KEY CLUSTERED 
(
	[TripReportId] ASC,
	[ReportMonth] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[TripReports]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TripReports]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[TripReports](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Filename] [nvarchar](250) NOT NULL,
	[Comments] [nvarchar](1000) NULL,
	[SpecialActivityId] [int] NOT NULL,
	[FileLocation] [nvarchar](500) NOT NULL,
	[CreatedByUserId] [int] NOT NULL,
 CONSTRAINT [PK_dbo.TripReports] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[UnregisteredCells]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UnregisteredCells]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[UnregisteredCells](
	[SMSNumber] [varchar](50) NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[UserAccessLevel]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UserAccessLevel]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[UserAccessLevel](
	[AccessLevelNo] [int] NOT NULL,
	[UserID] [varchar](50) NULL,
	[AccessID] [int] NULL,
	[AccessValue] [varchar](50) NULL
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[UserProfile]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UserProfile]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[UserProfile](
	[UserId] [int] IDENTITY(1,1) NOT NULL,
	[UserName] [nvarchar](56) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[UserId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
UNIQUE NONCLUSTERED 
(
	[UserName] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[Users]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Users]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Users](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Username] [nvarchar](100) NOT NULL,
	[FirstName] [nvarchar](100) NOT NULL,
	[LastName] [nvarchar](100) NOT NULL,
	[Password] [nvarchar](250) NOT NULL,
	[EmailAddress] [nvarchar](250) NOT NULL,
	[PhoneNumber] [nvarchar](50) NULL,
	[AccessLevelID] [int] NOT NULL,
	[AccessLevelValue] [nvarchar](50) NOT NULL,
	[Deleted] [bit] NOT NULL,
	[CreateDate] [datetime] NULL,
	[CreatedByUser] [int] NULL,
	[UpdateDate] [datetime] NULL,
	[UpdatedByUser] [int] NULL,
	[DeleteDate] [datetime] NULL,
	[DeletedByUser] [int] NULL,
	[SupportingPartnerId] [int] NOT NULL,
 CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[UserTitle]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UserTitle]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[UserTitle](
	[TitleID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](254) NOT NULL,
	[Description] [nvarchar](1000) NULL,
 CONSTRAINT [PK_UserTitle] PRIMARY KEY CLUSTERED 
(
	[TitleID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[UserType]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UserType]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[UserType](
	[UserTypeID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](100) NOT NULL,
	[Description] [nvarchar](1000) NULL,
 CONSTRAINT [PK_UserType] PRIMARY KEY CLUSTERED 
(
	[UserTypeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[webpages_Membership]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[webpages_Membership]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[webpages_Membership](
	[UserId] [int] NOT NULL,
	[CreateDate] [datetime] NULL,
	[ConfirmationToken] [nvarchar](128) NULL,
	[IsConfirmed] [bit] NULL,
	[LastPasswordFailureDate] [datetime] NULL,
	[PasswordFailuresSinceLastSuccess] [int] NOT NULL,
	[Password] [nvarchar](128) NOT NULL,
	[PasswordChangedDate] [datetime] NULL,
	[PasswordSalt] [nvarchar](128) NOT NULL,
	[PasswordVerificationToken] [nvarchar](128) NULL,
	[PasswordVerificationTokenExpirationDate] [datetime] NULL,
PRIMARY KEY CLUSTERED 
(
	[UserId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[webpages_OAuthMembership]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[webpages_OAuthMembership]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[webpages_OAuthMembership](
	[Provider] [nvarchar](30) NOT NULL,
	[ProviderUserId] [nvarchar](100) NOT NULL,
	[UserId] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[Provider] ASC,
	[ProviderUserId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[webpages_Roles]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[webpages_Roles]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[webpages_Roles](
	[RoleId] [int] IDENTITY(1,1) NOT NULL,
	[RoleName] [nvarchar](256) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[RoleId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
UNIQUE NONCLUSTERED 
(
	[RoleName] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[webpages_RolesUser]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[webpages_RolesUser]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[webpages_RolesUser](
	[webpages_Roles_RoleId] [int] NOT NULL,
	[User_ID] [int] NOT NULL,
 CONSTRAINT [PK_dbo.webpages_RolesUser] PRIMARY KEY CLUSTERED 
(
	[webpages_Roles_RoleId] ASC,
	[User_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[webpages_UsersInRoles]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[webpages_UsersInRoles]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[webpages_UsersInRoles](
	[UserId] [int] NOT NULL,
	[RoleId] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[UserId] ASC,
	[RoleId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  View [dbo].[ANC]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[ANC]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[ANC]
AS
SELECT     ReceivedSMS.ReceivedSMSNo, ReceivedSMS.FacCode, ReceivedSMS.Period AS [Month], ReceivedSMS.Year AS [Year], 
CAST(CAST(ReceivedSMS.Year AS varchar(4)) + ''-'' + CAST(ReceivedSMS.Period AS varchar(2)) + ''-01'' AS datetime) as [ReportDate], 
R.ANC01, R.ANC02, R.ANC03, 
                      R.ANC04, R.ANC05, R.ANC06, R.ANC07, R.ANC08, R.ANC09, R.ANC10, R.ANC11, R.ANC12, R.ANC13, R.ANC14 



FROM         ReceivedSMS INNER JOIN
                          (SELECT     ReceivedSMSNo, [4] AS [ANC01], [5] AS [ANC02], [6] AS [ANC03], [7] AS [ANC04], [8] AS [ANC05], [9] AS [ANC06], [10] AS [ANC07], 
                                                   [11] AS [ANC08], [12] AS [ANC09], [13] AS [ANC10], [14] AS [ANC11], [15] AS [ANC12], [16] AS [ANC13], [17] AS [ANC14]
                            FROM          (SELECT     ReceivedSMS.ReceivedSMSNo, ReceivedSMS.RepID, ReportData.DataPosition, CAST(ReportData.Data AS INT) AS [Data]
                                                    FROM          ReportData INNER JOIN
                                                                           ReceivedSMS ON ReportData.ReceivedSMSNo = ReceivedSMS.ReceivedSMSNo
                                                    WHERE      ReceivedSMS.RepID = 6) AS [DataSource] PIVOT (SUM(Data) FOR [DataPosition] IN ([4], [5], [6], [7], [8], [9], [10], [11], [12], [13], 
                                                   [14], [15], [16], [17])) AS P) AS R ON R.ReceivedSMSNo = ReceivedSMS.ReceivedSMSNo
' 
GO
/****** Object:  View [dbo].[PositiveTotalTested]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[PositiveTotalTested]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[PositiveTotalTested]
AS
SELECT     dbo.ANC.FacCode, dbo.Facilities.FacName, dbo.District.District, dbo.Region.RegionName, dbo.ANC.ANC02, dbo.ANC.ANC04, dbo.ANC.ANC05, 
                      dbo.ANC.ANC06, dbo.ANC.ANC07
FROM         dbo.Facilities INNER JOIN
                      dbo.District ON dbo.Facilities.District = dbo.District.DistrictNo INNER JOIN
                      dbo.ANC ON dbo.Facilities.FacCode = dbo.ANC.FacCode INNER JOIN
                      dbo.Region ON dbo.Facilities.Region = dbo.Region.RegionNo
WHERE     (dbo.ANC.ReportDate BETWEEN ''2011-10-01'' AND ''2012-09-01'') AND (dbo.ANC.ANC04 > 0) AND (dbo.ANC.ANC06 > 0)
' 
GO
/****** Object:  View [dbo].[ANC_MTUHA]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[ANC_MTUHA]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[ANC_MTUHA] AS
SELECT        ReceivedSMS.ReceivedSMSNo, ReceivedSMS.FacCode, ReceivedSMS.Period AS [Month], ReceivedSMS.Year AS [Year],
CAST(CAST(ReceivedSMS.Year AS varchar(4)) + ''-'' + CAST(ReceivedSMS.Period AS varchar(2)) + ''-01'' AS datetime) AS [ReportDate], 

R.[2a], R.[2b], R.[2c], R.[2d], R.[2e], R.[2f], R.[2g], R.[5a], R.[5b], R.[5c], R.[5d], R.[5e], R.[5f], R.[5g], R.[5h], R.[5i], R.[5j], R.[5k], R.[5l], R.[5m],
R.[5n], R.[5o], R.[5p], R.[5q]
FROM            ReceivedSMS INNER JOIN
(SELECT        ReceivedSMSNo, [4] AS [2a], [5] AS [2b], [6] AS [2c], [7] AS [2d], [8] AS [2e], [9] AS [2f], [10] AS [2g], [11] AS [5a], 
                            [12] AS [5b], [13] AS [5c], [14] AS [5d], [15] AS [5e], [16] AS [5f], [17] AS [5g], [18] AS [5h], [19] AS [5i], [20] AS [5j]
							, [21] AS [5k], [22] AS [5l], [23] AS [5m], [24] AS [5n], [25] AS [5o], [26] AS [5p], [27] AS [5q]
FROM            (SELECT        ReceivedSMS.ReceivedSMSNo, ReceivedSMS.RepID, ReportData.DataPosition, CAST(ReportData.Data AS INT) AS [Data]
                            FROM            ReportData INNER JOIN
                                                    ReceivedSMS ON ReportData.ReceivedSMSNo = ReceivedSMS.ReceivedSMSNo
                            WHERE        ReceivedSMS.RepID = 54) AS [DataSource] PIVOT (SUM(Data) FOR [DataPosition] IN ([4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], 
                            [16], [17],[18],[19],[20],[21],[22],[23],[24],[25],[26],[27])) AS P) AS R ON R.ReceivedSMSNo = ReceivedSMS.ReceivedSMSNo' 
GO
/****** Object:  View [dbo].[count_facilities]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[count_facilities]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[count_facilities]
AS
SELECT        dbo.Region.RegionCode AS [Region Code], dbo.Region.RegionName AS [Region Name], dbo.District.DistrictCode AS [District Code], 
                         dbo.District.District AS [District Name], COUNT(dbo.Facilities.FacCode) AS [Number of Facilities]
FROM            dbo.Facilities INNER JOIN
                         dbo.Region ON dbo.Facilities.Region = dbo.Region.RegionNo INNER JOIN
                         dbo.District ON dbo.District.DistrictNo = dbo.Facilities.District
GROUP BY dbo.Region.RegionCode, dbo.Region.RegionName, dbo.District.DistrictCode, dbo.District.District
' 
GO
/****** Object:  View [dbo].[eid_facilities]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[eid_facilities]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[eid_facilities]
AS
SELECT        dbo.Region.RegionCode AS [Region Code], dbo.Region.RegionName AS [Region Name], dbo.District.DistrictCode AS [District Code], 
                         dbo.District.District AS [District Name], dbo.Facilities.FacCode AS [Facility Code], dbo.Facilities.FacName AS [Facility Name], 
                         dbo.Facilities.DBSStartDate AS [Date of Starting EID]
FROM            dbo.Facilities INNER JOIN
                         dbo.District ON dbo.Facilities.District = dbo.District.DistrictNo INNER JOIN
                         dbo.Region ON dbo.Facilities.Region = dbo.Region.RegionNo
WHERE        (dbo.Facilities.ProvideDBS = 1)
' 
GO
/****** Object:  View [dbo].[eid_facilities_count]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[eid_facilities_count]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[eid_facilities_count]
AS
SELECT        dbo.District.DistrictCode AS [District Code], dbo.District.District AS [District Name], dbo.Region.RegionCode AS [Region Code], 
                         dbo.Region.RegionName AS [Region Name], COUNT(dbo.Facilities.FacCode) AS [Number of Facilities]
FROM            dbo.Facilities INNER JOIN
                         dbo.District ON dbo.District.DistrictNo = dbo.Facilities.District INNER JOIN
                         dbo.Region ON dbo.District.RegionNo = dbo.Region.RegionNo
WHERE        (dbo.Facilities.ProvideDBS = 1)
GROUP BY dbo.District.DistrictCode, dbo.District.District, dbo.Region.RegionCode, dbo.Region.RegionName
' 
GO
/****** Object:  View [dbo].[facilities_count_dispensaries]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[facilities_count_dispensaries]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[facilities_count_dispensaries]
AS
SELECT        dbo.Region.RegionCode AS [Region Code], dbo.Region.RegionName AS [Region Name], dbo.District.DistrictCode AS [District Code], 
                         dbo.District.District AS [District Name], dbo.Facilities.FacCode AS [Facility Code], dbo.Facilities.FacName AS [Facility Name]
FROM            dbo.Facilities INNER JOIN
                         dbo.Region ON dbo.Region.RegionNo = dbo.Facilities.Region INNER JOIN
                         dbo.District ON dbo.District.DistrictNo = dbo.Facilities.District
WHERE        (dbo.Facilities.FacilityType = 1)
' 
GO
/****** Object:  View [dbo].[facilities_count_health_centres]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[facilities_count_health_centres]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[facilities_count_health_centres]
AS
SELECT        dbo.Region.RegionCode AS [Region Code], dbo.Region.RegionName AS [Region Name], dbo.District.DistrictCode AS [District Code], 
                         dbo.District.District AS [District Name], dbo.Facilities.FacCode AS [Facility Code], dbo.Facilities.FacName AS [Facility Name]
FROM            dbo.Facilities INNER JOIN
                         dbo.Region ON dbo.Region.RegionNo = dbo.Facilities.Region INNER JOIN
                         dbo.District ON dbo.District.DistrictNo = dbo.Facilities.District
WHERE        (dbo.Facilities.FacilityType = 2)
' 
GO
/****** Object:  View [dbo].[facilities_count_hospitals]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[facilities_count_hospitals]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[facilities_count_hospitals]
AS
SELECT        dbo.Region.RegionCode AS [Region Code], dbo.Region.RegionName AS [Region Name], dbo.District.DistrictCode AS [District Code], 
                         dbo.District.District AS [District Name], dbo.Facilities.FacCode AS [Facility Code], dbo.Facilities.FacName AS [Facility Name]
FROM            dbo.Facilities INNER JOIN
                         dbo.Region ON dbo.Region.RegionNo = dbo.Facilities.Region INNER JOIN
                         dbo.District ON dbo.District.DistrictNo = dbo.Facilities.District
WHERE        (dbo.Facilities.FacilityType = 3)
' 
GO
/****** Object:  View [dbo].[facilities_count_types]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[facilities_count_types]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[facilities_count_types]
AS
SELECT        dbo.FacilityType.TypeName AS [Type of Facility], COUNT(dbo.Facilities.FacCode) AS [Number of Facilities]
FROM            dbo.Facilities INNER JOIN
                         dbo.FacilityType ON dbo.Facilities.FacilityType = dbo.FacilityType.TypeId
GROUP BY dbo.FacilityType.TypeName
' 
GO
/****** Object:  View [dbo].[facilities_count_types_districts]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[facilities_count_types_districts]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[facilities_count_types_districts]
AS
SELECT        dbo.Region.RegionCode AS [Region Code], dbo.Region.RegionName AS [Region Name], dbo.District.DistrictCode AS [District Code], 
                         dbo.District.District AS [District Name],
                             (SELECT        COUNT(FacCode) AS Expr1
                               FROM            dbo.Facilities
                               WHERE        (FacilityType = 1) AND (District = dbo.District.DistrictNo)) AS [Number of Dispensaries],
                             (SELECT        COUNT(FacCode) AS Expr1
                               FROM            dbo.Facilities AS Facilities_2
                               WHERE        (FacilityType = 2) AND (District = dbo.District.DistrictNo)) AS [Number of Health Centres],
                             (SELECT        COUNT(FacCode) AS Expr1
                               FROM            dbo.Facilities AS Facilities_1
                               WHERE        (FacilityType = 3) AND (District = dbo.District.DistrictNo)) AS [Number of Hospitals]
FROM            dbo.Region INNER JOIN
                         dbo.District ON dbo.Region.RegionNo = dbo.District.RegionNo
' 
GO
/****** Object:  View [dbo].[FacilitiesReports]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[FacilitiesReports]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[FacilitiesReports]
AS
SELECT     dbo.Facilities.Region AS RegionID, dbo.Region.RegionName, dbo.Facilities.District AS DistrictID, dbo.District.District AS DistrictName, 
                      dbo.ReceivedSMS.FacCode AS FacilityCode, dbo.Facilities.FacName AS FacilityName, dbo.ReportData.RepID AS ReportID, 
                      dbo.ReportData.DataPosition AS ReportDataPosition, dbo.ReportData.Data AS ReportData, dbo.ReceivedSMS.Year, dbo.ReceivedSMS.Period AS Month
FROM         dbo.ReportData INNER JOIN
                      dbo.ReceivedSMS ON dbo.ReportData.ReceivedSMSNo = dbo.ReceivedSMS.ReceivedSMSNo INNER JOIN
                      dbo.Facilities ON dbo.ReceivedSMS.FacCode = dbo.Facilities.FacCode INNER JOIN
                      dbo.District ON dbo.Facilities.District = dbo.District.DistrictNo INNER JOIN
                      dbo.Region ON dbo.Facilities.Region = dbo.Region.RegionNo
WHERE     (dbo.ReportData.DataPosition NOT BETWEEN 1 AND 3)
' 
GO
/****** Object:  View [dbo].[health_facilities]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[health_facilities]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[health_facilities] AS SELECT Region.RegionCode AS [Region Code],
  Region.RegionName AS [Region Name],
  District.DistrictCode AS [District Code],
  District.District AS [District Name],
  (SELECT Count(Facilities.FacilityType) FROM Facilities
  WHERE District.DistrictNo = Facilities.District AND Facilities.FacilityType =
    1) AS Dispensaries,
  (SELECT Count(Facilities.FacilityType) FROM Facilities
  WHERE District.DistrictNo = Facilities.District AND Facilities.FacilityType =
    2) AS [Health Centres],
  (SELECT Count(Facilities.FacilityType) FROM Facilities
  WHERE District.DistrictNo = Facilities.District AND Facilities.FacilityType =
    3) AS Hospital
FROM District
  INNER JOIN Region ON Region.RegionNo = District.RegionNo' 
GO
/****** Object:  View [dbo].[MAT]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[MAT]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[MAT]
AS
SELECT     ReceivedSMS.ReceivedSMSNo, ReceivedSMS.FacCode, ReceivedSMS.Period AS [Month], ReceivedSMS.Year AS [Year],
 
CAST(CAST(ReceivedSMS.Year AS varchar(4)) + ''-'' + CAST(ReceivedSMS.Period AS varchar(2)) + ''-01'' AS datetime) as [ReportDate],
 R.MAT01, R.MAT02, 
                      R.MAT03, R.MAT04, R.MAT05, R.MAT06, R.MAT07, R.MAT08, R.MAT09, R.MAT10, R.MAT11, R.MAT12, R.MAT13, R.MAT14, R.MAT15, R.MAT16, 
                      R.MAT17, R.MAT18
FROM         ReceivedSMS INNER JOIN
                          (SELECT     ReceivedSMSNo, [4] AS [MAT01], [5] AS [MAT02], [6] AS [MAT03], [7] AS [MAT04], [8] AS [MAT05], [9] AS [MAT06], [10] AS [MAT07], 
                                                   [11] AS [MAT08], [12] AS [MAT09], [13] AS [MAT10], [14] AS [MAT11], [15] AS [MAT12], [16] AS [MAT13], [17] AS [MAT14], [18] AS [MAT15], 
                                                   [19] AS [MAT16], [20] AS [MAT17], [21] AS [MAT18]
                            FROM          (SELECT     ReceivedSMS.ReceivedSMSNo, ReceivedSMS.RepID, ReportData.DataPosition, CAST(ReportData.Data AS INT) AS [Data]
                                                    FROM          ReportData INNER JOIN
                                                                           ReceivedSMS ON ReportData.ReceivedSMSNo = ReceivedSMS.ReceivedSMSNo
                                                    WHERE      ReceivedSMS.RepID = 7) AS [DataSource] PIVOT (SUM(Data) FOR [DataPosition] IN ([4], [5], [6], [7], [8], [9], [10], [11], [12], [13], 
                                                   [14], [15], [16], [17], [18], [19], [20], [21])) AS P) AS R ON R.ReceivedSMSNo = ReceivedSMS.ReceivedSMSNo
' 
GO
/****** Object:  View [dbo].[MAT_MTUHA]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[MAT_MTUHA]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[MAT_MTUHA] AS
SELECT        ReceivedSMS.ReceivedSMSNo, ReceivedSMS.FacCode, ReceivedSMS.Period AS [Month], ReceivedSMS.Year AS [Year],
CAST(CAST(ReceivedSMS.Year AS varchar(4)) + ''-'' + CAST(ReceivedSMS.Period AS varchar(2)) + ''-01'' AS datetime) AS [ReportDate], 

R.[2a], R.[2b], R.[2c], R.[2d], R.[2e], R.[2f], R.[2g], R.[8a], R.[8b], R.[8c], R.[8d], R.[8e], R.[8f], R.[8g], R.[8h], R.[8i], R.[8j], R.[8k], R.[8l], R.[8m],
R.[8n]
FROM            ReceivedSMS INNER JOIN
(SELECT        ReceivedSMSNo, [4] AS [2a], [5] AS [2b], [6] AS [2c], [7] AS [2d], [8] AS [2e], [9] AS [2f], [10] AS [2g], [11] AS [8a], 
                            [12] AS [8b], [13] AS [8c], [14] AS [8d], [15] AS [8e], [16] AS [8f], [17] AS [8g], [18] AS [8h], [19] AS [8i], [20] AS [8j]
							, [21] AS [8k], [22] AS [8l], [23] AS [8m], [24] AS [8n]
FROM            (SELECT        ReceivedSMS.ReceivedSMSNo, ReceivedSMS.RepID, ReportData.DataPosition, CAST(ReportData.Data AS INT) AS [Data]
                            FROM            ReportData INNER JOIN
                                                    ReceivedSMS ON ReportData.ReceivedSMSNo = ReceivedSMS.ReceivedSMSNo
                            WHERE        ReceivedSMS.RepID = 55) AS [DataSource] PIVOT (SUM(Data) FOR [DataPosition] IN ([4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], 
                            [16], [17],[18],[19],[20],[21],[22],[23],[24])) AS P) AS R ON R.ReceivedSMSNo = ReceivedSMS.ReceivedSMSNo' 
GO
/****** Object:  View [dbo].[MC]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[MC]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[MC]
AS
SELECT     ReceivedSMS.ReceivedSMSNo, ReceivedSMS.FacCode, ReceivedSMS.Period AS [Month], ReceivedSMS.Year AS [Year], 

 
CAST(CAST(ReceivedSMS.Year AS varchar(4)) + ''-'' + CAST(ReceivedSMS.Period AS varchar(2)) + ''-01'' AS datetime) as [ReportDate],

R.MC01, R.MC02, R.MC03, 
                      R.MC04, R.MC05, R.MC06, R.MC07, R.MC08, R.MC09, R.MC10, R.MC11, R.MC12, R.MC13, R.MC14, R.MC15, R.MC16, R.MC17, R.MC18, R.MC19, 
                      R.MC20
FROM         ReceivedSMS INNER JOIN
                          (SELECT     ReceivedSMSNo, [4] AS [MC01], [5] AS [MC02], [6] AS [MC03], [7] AS [MC04], [8] AS [MC05], [9] AS [MC06], [10] AS [MC07], [11] AS [MC08], 
                                                   [12] AS [MC09], [13] AS [MC10], [14] AS [MC11], [15] AS [MC12], [16] AS [MC13], [17] AS [MC14], [18] AS [MC15], [19] AS [MC16], 
                                                   [20] AS [MC17], [21] AS [MC18], [22] AS [MC19], [23] AS [MC20]
                            FROM          (SELECT     ReceivedSMS.ReceivedSMSNo, ReceivedSMS.RepID, ReportData.DataPosition, CAST(ReportData.Data AS INT) AS [Data]
                                                    FROM          ReportData INNER JOIN
                                                                           ReceivedSMS ON ReportData.ReceivedSMSNo = ReceivedSMS.ReceivedSMSNo
                                                    WHERE      ReceivedSMS.RepID = 9) AS [DataSource] PIVOT (SUM(Data) FOR [DataPosition] IN ([4], [5], [6], [7], [8], [9], [10], [11], [12], [13], 
                                                   [14], [15], [16], [17], [18], [19], [20], [21], [22], [23])) AS P) AS R ON R.ReceivedSMSNo = ReceivedSMS.ReceivedSMSNo
' 
GO
/****** Object:  View [dbo].[MC_MTUHA]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[MC_MTUHA]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[MC_MTUHA] AS
SELECT        ReceivedSMS.ReceivedSMSNo, ReceivedSMS.FacCode, ReceivedSMS.Period AS [Month], ReceivedSMS.Year AS [Year], 
                         CAST(CAST(ReceivedSMS.Year AS varchar(4)) + ''-'' + CAST(ReceivedSMS.Period AS varchar(2)) + ''-01'' AS datetime) AS [ReportDate], R.MC01, R.MC02, R.MC03, 
                         R.MC04, R.MC05, R.MC06, R.MC07, R.MC08, R.MC09, R.MC10, R.MC11, R.MC12, R.MC13, R.MC14, R.MC15, R.MC16, R.MC17, R.MC18, R.MC19
FROM            ReceivedSMS INNER JOIN
                             (SELECT        ReceivedSMSNo, [4] AS [MC01], [5] AS [MC02], [6] AS [MC03], [7] AS [MC04], [8] AS [MC05], [9] AS [MC06], [10] AS [MC07], [11] AS [MC08], 
                                                         [12] AS [MC09], [13] AS [MC10], [14] AS [MC11], [15] AS [MC12], [16] AS [MC13], [17] AS [MC14], [18] AS [MC15], [19] AS [MC16], [20] AS [MC17], 
                                                         [21] AS [MC18], [22] AS [MC19]
                               FROM            (SELECT        ReceivedSMS.ReceivedSMSNo, ReceivedSMS.RepID, ReportData.DataPosition, CAST(ReportData.Data AS INT) AS [Data]
                                                         FROM            ReportData INNER JOIN
                                                                                   ReceivedSMS ON ReportData.ReceivedSMSNo = ReceivedSMS.ReceivedSMSNo
                                                         WHERE        ReceivedSMS.RepID = 42) AS [DataSource] PIVOT (SUM(Data) FOR [DataPosition] IN ([4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], 
                                                         [16], [17], [18], [19], [20], [21], [22])) AS P) AS R ON R.ReceivedSMSNo = ReceivedSMS.ReceivedSMSNo' 
GO
/****** Object:  View [dbo].[missing_stock_status]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[missing_stock_status]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[missing_stock_status] AS SELECT Region.RegionCode AS [Region Code],
  Region.RegionName AS [Region Name],
  District.DistrictCode AS [District Code],
  District.District AS [District Name],
  Facilities.FacCode AS [Facility Code],
  Facilities.FacName AS [Facility Name]
FROM Facilities
  INNER JOIN District ON District.DistrictNo = Facilities.District
  INNER JOIN Region ON Facilities.Region = Region.RegionNo
WHERE Facilities.FacCode NOT IN (SELECT StockStatus.FacCode FROM StockStatus)' 
GO
/****** Object:  View [dbo].[PCR]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[PCR]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[PCR]
AS
SELECT     ReceivedSMS.ReceivedSMSNo, ReceivedSMS.FacCode, ReceivedSMS.Period AS [Month], ReceivedSMS.Year AS [Year], 
 
CAST(CAST(ReceivedSMS.Year AS varchar(4)) + ''-'' + CAST(ReceivedSMS.Period AS varchar(2)) + ''-01'' AS datetime) as [ReportDate],

R.PCR01, R.PCR02, 
                      R.PCR03, R.PCR04, R.PCR05, R.PCR06, R.PCR07, R.PCR08, R.PCR09, R.PCR10, R.PCR11, R.PCR12, R.PCR13
FROM         ReceivedSMS INNER JOIN
                          (SELECT     ReceivedSMSNo, [4] AS [PCR01], [5] AS [PCR02], [6] AS [PCR03], [7] AS [PCR04], [8] AS [PCR05], [9] AS [PCR06], [10] AS [PCR07], 
                                                   [11] AS [PCR08], [12] AS [PCR09], [13] AS [PCR10], [14] AS [PCR11], [15] AS [PCR12], [16] AS [PCR13]
                            FROM          (SELECT     ReceivedSMS.ReceivedSMSNo, ReceivedSMS.RepID, ReportData.DataPosition, CAST(ReportData.Data AS INT) AS [Data]
                                                    FROM          ReportData INNER JOIN
                                                                           ReceivedSMS ON ReportData.ReceivedSMSNo = ReceivedSMS.ReceivedSMSNo
                                                    WHERE      ReceivedSMS.RepID = 8) AS [DataSource] PIVOT (SUM(Data) FOR [DataPosition] IN ([4], [5], [6], [7], [8], [9], [10], [11], [12], [13], 
                                                   [14], [15], [16])) AS P) AS R ON R.ReceivedSMSNo = ReceivedSMS.ReceivedSMSNo
' 
GO
/****** Object:  View [dbo].[testing_tools_stock]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[testing_tools_stock]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[testing_tools_stock] AS SELECT Region.RegionCode AS [Region Code],
  Region.RegionName AS [Region Name],
  District.DistrictCode AS [District Code],
  District.District AS [District Name],
  Facilities.FacCode AS [Facility Code],
  Facilities.FacName AS [Facility Name],
  StockStatus.RequiredDetermine AS [Available Determine],
  StockStatus.RequiredUnigold AS [Available Unigold],
  StockStatus.RequiredDBS AS [Available DBS]
FROM StockStatus
  INNER JOIN Facilities ON StockStatus.FacCode = Facilities.FacCode
  INNER JOIN District ON District.DistrictNo = Facilities.District
  INNER JOIN Region ON Facilities.Region = Region.RegionNo' 
GO
/****** Object:  View [dbo].[users_SMS]    Script Date: 18/Jan/2015 11:37:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[users_SMS]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[users_SMS]
AS
SELECT        dbo.ApprovedSMSCells.CellNum, dbo.ApprovedSMSCells.Name, dbo.ApprovedSMSCells.Email, dbo.Languages.Language, dbo.Facilities.FacCode, 
                         dbo.Facilities.FacName, dbo.District.DistrictCode, dbo.District.District, dbo.Region.RegionCode, dbo.Region.RegionName
FROM            dbo.ApprovedSMSCells INNER JOIN
                         dbo.Facilities ON dbo.ApprovedSMSCells.FacCode = dbo.Facilities.FacCode INNER JOIN
                         dbo.District ON dbo.Facilities.District = dbo.District.DistrictNo INNER JOIN
                         dbo.Languages ON dbo.ApprovedSMSCells.LangID = dbo.Languages.LangID INNER JOIN
                         dbo.Region ON dbo.Facilities.Region = dbo.Region.RegionNo
' 
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__ANCForm_PM__C_5n__53385258]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ANCForm_PMTCT] ADD  DEFAULT ((0)) FOR [C_5n]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__ANCForm_PM__C_5o__542C7691]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ANCForm_PMTCT] ADD  DEFAULT ((0)) FOR [C_5o]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__ANCForm_PM__C_5p__55209ACA]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ANCForm_PMTCT] ADD  DEFAULT ((0)) FOR [C_5p]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__ANCForm_PM__C_5q__5614BF03]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ANCForm_PMTCT] ADD  DEFAULT ((0)) FOR [C_5q]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__ANCForm_Vi__C_4l__5708E33C]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ANCForm_VidokezoVyaHatari] ADD  DEFAULT ((0)) FOR [C_4l]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__ANCForm_Vi__C_4m__57FD0775]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ANCForm_VidokezoVyaHatari] ADD  DEFAULT ((0)) FOR [C_4m]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__ANCForm_Vi__C_4n__58F12BAE]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ANCForm_VidokezoVyaHatari] ADD  DEFAULT ((0)) FOR [C_4n]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__ANCForm_Vi__C_4o__59E54FE7]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ANCForm_VidokezoVyaHatari] ADD  DEFAULT ((0)) FOR [C_4o]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__ANCForm_Vi__C_4p__5AD97420]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ANCForm_VidokezoVyaHatari] ADD  DEFAULT ((0)) FOR [C_4p]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__ANCForm_Vi__C_4q__5BCD9859]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ANCForm_VidokezoVyaHatari] ADD  DEFAULT ((0)) FOR [C_4q]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__ANCForm_Vi__C_4r__5CC1BC92]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ANCForm_VidokezoVyaHatari] ADD  DEFAULT ((0)) FOR [C_4r]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF_ApprovedSMSCells_SendSMS]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ApprovedSMSCells] ADD  CONSTRAINT [DF_ApprovedSMSCells_SendSMS]  DEFAULT ((1)) FOR [SendSMS]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__Associated__MC10__7834CCDD]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[AssociatedEarlyInfantDiagnosis] ADD  DEFAULT ((0)) FOR [MC10]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__Associated__MC11__7928F116]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[AssociatedEarlyInfantDiagnosis] ADD  DEFAULT ((0)) FOR [MC11]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__Associated__MC12__7A1D154F]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[AssociatedEarlyInfantDiagnosis] ADD  DEFAULT ((0)) FOR [MC12]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__Associated__MC13__7B113988]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[AssociatedEarlyInfantDiagnosis] ADD  DEFAULT ((0)) FOR [MC13]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__Associated__MC14__7C055DC1]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[AssociatedEarlyInfantDiagnosis] ADD  DEFAULT ((0)) FOR [MC14]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__Associated__MC15__7CF981FA]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[AssociatedEarlyInfantDiagnosis] ADD  DEFAULT ((0)) FOR [MC15]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF_ExpectedReports_ReportingStartDate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ExpectedReports] ADD  CONSTRAINT [DF_ExpectedReports_ReportingStartDate]  DEFAULT (getdate()) FOR [ReportingStartDate]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF_ExpectedReports_DirectEntry]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ExpectedReports] ADD  CONSTRAINT [DF_ExpectedReports_DirectEntry]  DEFAULT ((1)) FOR [DirectEntry]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__LDForm_Mat__C_4j__5DB5E0CB]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[LDForm_MatatizoKablaYaKujifungua] ADD  DEFAULT ((0)) FOR [C_4j]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__LDForm_Mat__C_4k__5EAA0504]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[LDForm_MatatizoKablaYaKujifungua] ADD  DEFAULT ((0)) FOR [C_4k]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__LDForm_Wa__C_10a__34B3CB38]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[LDForm_WatotoWaliozaliwaMapacha] ADD  DEFAULT ((0)) FOR [C_10a]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__LDForm_Wa__C_10b__35A7EF71]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[LDForm_WatotoWaliozaliwaMapacha] ADD  DEFAULT ((0)) FOR [C_10b]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__LDForm_Wa__C_10c__369C13AA]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[LDForm_WatotoWaliozaliwaMapacha] ADD  DEFAULT ((0)) FOR [C_10c]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__LDForm_Wa__C_10d__379037E3]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[LDForm_WatotoWaliozaliwaMapacha] ADD  DEFAULT ((0)) FOR [C_10d]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__LDForm_Wa__C_10e__38845C1C]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[LDForm_WatotoWaliozaliwaMapacha] ADD  DEFAULT ((0)) FOR [C_10e]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__LDForm_Wa__C_10f__39788055]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[LDForm_WatotoWaliozaliwaMapacha] ADD  DEFAULT ((0)) FOR [C_10f]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__LDForm_Wa__C_10g__3A6CA48E]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[LDForm_WatotoWaliozaliwaMapacha] ADD  DEFAULT ((0)) FOR [C_10g]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__LDForm_Wa__C_10h__3B60C8C7]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[LDForm_WatotoWaliozaliwaMapacha] ADD  DEFAULT ((0)) FOR [C_10h]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__LDForm_Wa__C_10i__5F9E293D]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[LDForm_WatotoWaliozaliwaMapacha] ADD  DEFAULT ((0)) FOR [C_10i]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__OptionBPl__HasCT__1229A90A]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[OptionBPlusFacilities] ADD  DEFAULT ((0)) FOR [HasCTC]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__OptionBPl__HasCT__00FF1D08]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[OptionBPlusFacilities[Dump]]] ADD  DEFAULT ((0)) FOR [HasCTC]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF_QueryCategories_Deleted]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[QueryCategories] ADD  CONSTRAINT [DF_QueryCategories_Deleted]  DEFAULT ((0)) FOR [Deleted]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF_Report_UsedAsView]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Report] ADD  CONSTRAINT [DF_Report_UsedAsView]  DEFAULT ((1)) FOR [UsedAsView]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF_StockStatus_ReportDate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[StockStatus] ADD  CONSTRAINT [DF_StockStatus_ReportDate]  DEFAULT (getdate()) FOR [DateReportReceived]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__TripRepor__FileL__0E240DFC]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[TripReports] ADD  DEFAULT ('') FOR [FileLocation]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__TripRepor__Creat__0F183235]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[TripReports] ADD  DEFAULT ((0)) FOR [CreatedByUserId]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF_Users_Deleted]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Users] ADD  CONSTRAINT [DF_Users_Deleted]  DEFAULT ((0)) FOR [Deleted]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__webpages___IsCon__4959E263]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[webpages_Membership] ADD  DEFAULT ((0)) FOR [IsConfirmed]
END

GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DF__webpages___Passw__4A4E069C]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[webpages_Membership] ADD  DEFAULT ((0)) FOR [PasswordFailuresSinceLastSuccess]
END

GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_ANCForm_HudhurioLaKwanza]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm]'))
ALTER TABLE [dbo].[ANCForm]  WITH CHECK ADD  CONSTRAINT [FK_ANCForm_ANCForm_HudhurioLaKwanza] FOREIGN KEY([HudhurioLaKwanza_2id])
REFERENCES [dbo].[ANCForm_HudhurioLaKwanza] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_ANCForm_HudhurioLaKwanza]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm]'))
ALTER TABLE [dbo].[ANCForm] CHECK CONSTRAINT [FK_ANCForm_ANCForm_HudhurioLaKwanza]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_ANCForm_Malaria]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm]'))
ALTER TABLE [dbo].[ANCForm]  WITH CHECK ADD  CONSTRAINT [FK_ANCForm_ANCForm_Malaria] FOREIGN KEY([Malaria_6id])
REFERENCES [dbo].[ANCForm_Malaria] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_ANCForm_Malaria]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm]'))
ALTER TABLE [dbo].[ANCForm] CHECK CONSTRAINT [FK_ANCForm_ANCForm_Malaria]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_ANCForm_PMTCT]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm]'))
ALTER TABLE [dbo].[ANCForm]  WITH CHECK ADD  CONSTRAINT [FK_ANCForm_ANCForm_PMTCT] FOREIGN KEY([PMTCT_5id])
REFERENCES [dbo].[ANCForm_PMTCT] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_ANCForm_PMTCT]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm]'))
ALTER TABLE [dbo].[ANCForm] CHECK CONSTRAINT [FK_ANCForm_ANCForm_PMTCT]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_ANCForm_VidokezoVyaHatari]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm]'))
ALTER TABLE [dbo].[ANCForm]  WITH CHECK ADD  CONSTRAINT [FK_ANCForm_ANCForm_VidokezoVyaHatari] FOREIGN KEY([VidokezoVyaHatari_4id])
REFERENCES [dbo].[ANCForm_VidokezoVyaHatari] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_ANCForm_VidokezoVyaHatari]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm]'))
ALTER TABLE [dbo].[ANCForm] CHECK CONSTRAINT [FK_ANCForm_ANCForm_VidokezoVyaHatari]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_ANCFormMetadata]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm]'))
ALTER TABLE [dbo].[ANCForm]  WITH CHECK ADD  CONSTRAINT [FK_ANCForm_ANCFormMetadata] FOREIGN KEY([MetadataId])
REFERENCES [dbo].[ANCFormMetadata] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_ANCFormMetadata]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm]'))
ALTER TABLE [dbo].[ANCForm] CHECK CONSTRAINT [FK_ANCForm_ANCFormMetadata]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_Facilities]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm]'))
ALTER TABLE [dbo].[ANCForm]  WITH CHECK ADD  CONSTRAINT [FK_ANCForm_Facilities] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_Facilities]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm]'))
ALTER TABLE [dbo].[ANCForm] CHECK CONSTRAINT [FK_ANCForm_Facilities]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ANCForm_dbo.ANCFormMetadata_MetadataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm]'))
ALTER TABLE [dbo].[ANCForm]  WITH CHECK ADD  CONSTRAINT [FK_dbo.ANCForm_dbo.ANCFormMetadata_MetadataId] FOREIGN KEY([MetadataId])
REFERENCES [dbo].[ANCFormMetadata] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ANCForm_dbo.ANCFormMetadata_MetadataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm]'))
ALTER TABLE [dbo].[ANCForm] CHECK CONSTRAINT [FK_dbo.ANCForm_dbo.ANCFormMetadata_MetadataId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ANCForm_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm]'))
ALTER TABLE [dbo].[ANCForm]  WITH CHECK ADD  CONSTRAINT [FK_dbo.ANCForm_dbo.Facilities_FacilityCode] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ANCForm_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm]'))
ALTER TABLE [dbo].[ANCForm] CHECK CONSTRAINT [FK_dbo.ANCForm_dbo.Facilities_FacilityCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_HudhurioLaKwanza_ANCFormMetadata]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_HudhurioLaKwanza]'))
ALTER TABLE [dbo].[ANCForm_HudhurioLaKwanza]  WITH CHECK ADD  CONSTRAINT [FK_ANCForm_HudhurioLaKwanza_ANCFormMetadata] FOREIGN KEY([MetadataId])
REFERENCES [dbo].[ANCFormMetadata] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_HudhurioLaKwanza_ANCFormMetadata]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_HudhurioLaKwanza]'))
ALTER TABLE [dbo].[ANCForm_HudhurioLaKwanza] CHECK CONSTRAINT [FK_ANCForm_HudhurioLaKwanza_ANCFormMetadata]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_HudhurioLaKwanza_Facilities]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_HudhurioLaKwanza]'))
ALTER TABLE [dbo].[ANCForm_HudhurioLaKwanza]  WITH CHECK ADD  CONSTRAINT [FK_ANCForm_HudhurioLaKwanza_Facilities] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_HudhurioLaKwanza_Facilities]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_HudhurioLaKwanza]'))
ALTER TABLE [dbo].[ANCForm_HudhurioLaKwanza] CHECK CONSTRAINT [FK_ANCForm_HudhurioLaKwanza_Facilities]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ANCForm_HudhurioLaKwanza_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_HudhurioLaKwanza]'))
ALTER TABLE [dbo].[ANCForm_HudhurioLaKwanza]  WITH CHECK ADD  CONSTRAINT [FK_dbo.ANCForm_HudhurioLaKwanza_dbo.Facilities_FacilityCode] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ANCForm_HudhurioLaKwanza_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_HudhurioLaKwanza]'))
ALTER TABLE [dbo].[ANCForm_HudhurioLaKwanza] CHECK CONSTRAINT [FK_dbo.ANCForm_HudhurioLaKwanza_dbo.Facilities_FacilityCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_Malaria_ANCFormMetadata]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_Malaria]'))
ALTER TABLE [dbo].[ANCForm_Malaria]  WITH CHECK ADD  CONSTRAINT [FK_ANCForm_Malaria_ANCFormMetadata] FOREIGN KEY([MetadataId])
REFERENCES [dbo].[ANCFormMetadata] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_Malaria_ANCFormMetadata]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_Malaria]'))
ALTER TABLE [dbo].[ANCForm_Malaria] CHECK CONSTRAINT [FK_ANCForm_Malaria_ANCFormMetadata]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_Malaria_Facilities]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_Malaria]'))
ALTER TABLE [dbo].[ANCForm_Malaria]  WITH CHECK ADD  CONSTRAINT [FK_ANCForm_Malaria_Facilities] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_Malaria_Facilities]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_Malaria]'))
ALTER TABLE [dbo].[ANCForm_Malaria] CHECK CONSTRAINT [FK_ANCForm_Malaria_Facilities]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ANCForm_Malaria_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_Malaria]'))
ALTER TABLE [dbo].[ANCForm_Malaria]  WITH CHECK ADD  CONSTRAINT [FK_dbo.ANCForm_Malaria_dbo.Facilities_FacilityCode] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ANCForm_Malaria_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_Malaria]'))
ALTER TABLE [dbo].[ANCForm_Malaria] CHECK CONSTRAINT [FK_dbo.ANCForm_Malaria_dbo.Facilities_FacilityCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_PMTCT_ANCFormMetadata]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_PMTCT]'))
ALTER TABLE [dbo].[ANCForm_PMTCT]  WITH CHECK ADD  CONSTRAINT [FK_ANCForm_PMTCT_ANCFormMetadata] FOREIGN KEY([MetadataId])
REFERENCES [dbo].[ANCFormMetadata] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_PMTCT_ANCFormMetadata]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_PMTCT]'))
ALTER TABLE [dbo].[ANCForm_PMTCT] CHECK CONSTRAINT [FK_ANCForm_PMTCT_ANCFormMetadata]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_PMTCT_Facilities]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_PMTCT]'))
ALTER TABLE [dbo].[ANCForm_PMTCT]  WITH CHECK ADD  CONSTRAINT [FK_ANCForm_PMTCT_Facilities] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_PMTCT_Facilities]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_PMTCT]'))
ALTER TABLE [dbo].[ANCForm_PMTCT] CHECK CONSTRAINT [FK_ANCForm_PMTCT_Facilities]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ANCForm_PMTCT_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_PMTCT]'))
ALTER TABLE [dbo].[ANCForm_PMTCT]  WITH CHECK ADD  CONSTRAINT [FK_dbo.ANCForm_PMTCT_dbo.Facilities_FacilityCode] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ANCForm_PMTCT_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_PMTCT]'))
ALTER TABLE [dbo].[ANCForm_PMTCT] CHECK CONSTRAINT [FK_dbo.ANCForm_PMTCT_dbo.Facilities_FacilityCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_VidokezoVyaHatari_ANCFormMetadata]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_VidokezoVyaHatari]'))
ALTER TABLE [dbo].[ANCForm_VidokezoVyaHatari]  WITH CHECK ADD  CONSTRAINT [FK_ANCForm_VidokezoVyaHatari_ANCFormMetadata] FOREIGN KEY([MetadataId])
REFERENCES [dbo].[ANCFormMetadata] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_VidokezoVyaHatari_ANCFormMetadata]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_VidokezoVyaHatari]'))
ALTER TABLE [dbo].[ANCForm_VidokezoVyaHatari] CHECK CONSTRAINT [FK_ANCForm_VidokezoVyaHatari_ANCFormMetadata]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_VidokezoVyaHatari_Facilities]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_VidokezoVyaHatari]'))
ALTER TABLE [dbo].[ANCForm_VidokezoVyaHatari]  WITH CHECK ADD  CONSTRAINT [FK_ANCForm_VidokezoVyaHatari_Facilities] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCForm_VidokezoVyaHatari_Facilities]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_VidokezoVyaHatari]'))
ALTER TABLE [dbo].[ANCForm_VidokezoVyaHatari] CHECK CONSTRAINT [FK_ANCForm_VidokezoVyaHatari_Facilities]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ANCForm_VidokezoVyaHatari_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_VidokezoVyaHatari]'))
ALTER TABLE [dbo].[ANCForm_VidokezoVyaHatari]  WITH CHECK ADD  CONSTRAINT [FK_dbo.ANCForm_VidokezoVyaHatari_dbo.Facilities_FacilityCode] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ANCForm_VidokezoVyaHatari_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCForm_VidokezoVyaHatari]'))
ALTER TABLE [dbo].[ANCForm_VidokezoVyaHatari] CHECK CONSTRAINT [FK_dbo.ANCForm_VidokezoVyaHatari_dbo.Facilities_FacilityCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCFormMetadata_DataInputMethod]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCFormMetadata]'))
ALTER TABLE [dbo].[ANCFormMetadata]  WITH CHECK ADD  CONSTRAINT [FK_ANCFormMetadata_DataInputMethod] FOREIGN KEY([InputMethodId])
REFERENCES [dbo].[DataInputMethod] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ANCFormMetadata_DataInputMethod]') AND parent_object_id = OBJECT_ID(N'[dbo].[ANCFormMetadata]'))
ALTER TABLE [dbo].[ANCFormMetadata] CHECK CONSTRAINT [FK_ANCFormMetadata_DataInputMethod]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.AssociatedEarlyInfantDiagnosis_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[AssociatedEarlyInfantDiagnosis]'))
ALTER TABLE [dbo].[AssociatedEarlyInfantDiagnosis]  WITH CHECK ADD  CONSTRAINT [FK_dbo.AssociatedEarlyInfantDiagnosis_dbo.Facilities_FacilityCode] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.AssociatedEarlyInfantDiagnosis_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[AssociatedEarlyInfantDiagnosis]'))
ALTER TABLE [dbo].[AssociatedEarlyInfantDiagnosis] CHECK CONSTRAINT [FK_dbo.AssociatedEarlyInfantDiagnosis_dbo.Facilities_FacilityCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.AssociatedEarlyInfantDiagnosis_dbo.TestingAndCounselings_CounselingAndTestingId]') AND parent_object_id = OBJECT_ID(N'[dbo].[AssociatedEarlyInfantDiagnosis]'))
ALTER TABLE [dbo].[AssociatedEarlyInfantDiagnosis]  WITH CHECK ADD  CONSTRAINT [FK_dbo.AssociatedEarlyInfantDiagnosis_dbo.TestingAndCounselings_CounselingAndTestingId] FOREIGN KEY([CounselingAndTestingId])
REFERENCES [dbo].[TestingAndCounselings] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.AssociatedEarlyInfantDiagnosis_dbo.TestingAndCounselings_CounselingAndTestingId]') AND parent_object_id = OBJECT_ID(N'[dbo].[AssociatedEarlyInfantDiagnosis]'))
ALTER TABLE [dbo].[AssociatedEarlyInfantDiagnosis] CHECK CONSTRAINT [FK_dbo.AssociatedEarlyInfantDiagnosis_dbo.TestingAndCounselings_CounselingAndTestingId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.AssociatedEarlyInfantDiagnosis_dbo.Timeframes_TimeframeId]') AND parent_object_id = OBJECT_ID(N'[dbo].[AssociatedEarlyInfantDiagnosis]'))
ALTER TABLE [dbo].[AssociatedEarlyInfantDiagnosis]  WITH CHECK ADD  CONSTRAINT [FK_dbo.AssociatedEarlyInfantDiagnosis_dbo.Timeframes_TimeframeId] FOREIGN KEY([TimeframeId])
REFERENCES [dbo].[Timeframes] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.AssociatedEarlyInfantDiagnosis_dbo.Timeframes_TimeframeId]') AND parent_object_id = OBJECT_ID(N'[dbo].[AssociatedEarlyInfantDiagnosis]'))
ALTER TABLE [dbo].[AssociatedEarlyInfantDiagnosis] CHECK CONSTRAINT [FK_dbo.AssociatedEarlyInfantDiagnosis_dbo.Timeframes_TimeframeId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.AssociatedEarlyInfantDiagnosis_dbo.Users_CreatedByUserId]') AND parent_object_id = OBJECT_ID(N'[dbo].[AssociatedEarlyInfantDiagnosis]'))
ALTER TABLE [dbo].[AssociatedEarlyInfantDiagnosis]  WITH CHECK ADD  CONSTRAINT [FK_dbo.AssociatedEarlyInfantDiagnosis_dbo.Users_CreatedByUserId] FOREIGN KEY([CreatedByUserId])
REFERENCES [dbo].[Users] ([ID])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.AssociatedEarlyInfantDiagnosis_dbo.Users_CreatedByUserId]') AND parent_object_id = OBJECT_ID(N'[dbo].[AssociatedEarlyInfantDiagnosis]'))
ALTER TABLE [dbo].[AssociatedEarlyInfantDiagnosis] CHECK CONSTRAINT [FK_dbo.AssociatedEarlyInfantDiagnosis_dbo.Users_CreatedByUserId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.AssociatedEarlyInfantDiagnosis_dbo.Users_UpdatedByUserId]') AND parent_object_id = OBJECT_ID(N'[dbo].[AssociatedEarlyInfantDiagnosis]'))
ALTER TABLE [dbo].[AssociatedEarlyInfantDiagnosis]  WITH CHECK ADD  CONSTRAINT [FK_dbo.AssociatedEarlyInfantDiagnosis_dbo.Users_UpdatedByUserId] FOREIGN KEY([UpdatedByUserId])
REFERENCES [dbo].[Users] ([ID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.AssociatedEarlyInfantDiagnosis_dbo.Users_UpdatedByUserId]') AND parent_object_id = OBJECT_ID(N'[dbo].[AssociatedEarlyInfantDiagnosis]'))
ALTER TABLE [dbo].[AssociatedEarlyInfantDiagnosis] CHECK CONSTRAINT [FK_dbo.AssociatedEarlyInfantDiagnosis_dbo.Users_UpdatedByUserId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_AutoReminderDistricts_District]') AND parent_object_id = OBJECT_ID(N'[dbo].[AutoReminderDistricts]'))
ALTER TABLE [dbo].[AutoReminderDistricts]  WITH CHECK ADD  CONSTRAINT [FK_AutoReminderDistricts_District] FOREIGN KEY([DistrictId])
REFERENCES [dbo].[District] ([DistrictNo])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_AutoReminderDistricts_District]') AND parent_object_id = OBJECT_ID(N'[dbo].[AutoReminderDistricts]'))
ALTER TABLE [dbo].[AutoReminderDistricts] CHECK CONSTRAINT [FK_AutoReminderDistricts_District]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_AutoReminderFacilities_Facilities]') AND parent_object_id = OBJECT_ID(N'[dbo].[AutoReminderFacilities]'))
ALTER TABLE [dbo].[AutoReminderFacilities]  WITH CHECK ADD  CONSTRAINT [FK_AutoReminderFacilities_Facilities] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_AutoReminderFacilities_Facilities]') AND parent_object_id = OBJECT_ID(N'[dbo].[AutoReminderFacilities]'))
ALTER TABLE [dbo].[AutoReminderFacilities] CHECK CONSTRAINT [FK_AutoReminderFacilities_Facilities]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_AutoReminderRegions_Region]') AND parent_object_id = OBJECT_ID(N'[dbo].[AutoReminderRegions]'))
ALTER TABLE [dbo].[AutoReminderRegions]  WITH CHECK ADD  CONSTRAINT [FK_AutoReminderRegions_Region] FOREIGN KEY([RegionId])
REFERENCES [dbo].[Region] ([RegionNo])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_AutoReminderRegions_Region]') AND parent_object_id = OBJECT_ID(N'[dbo].[AutoReminderRegions]'))
ALTER TABLE [dbo].[AutoReminderRegions] CHECK CONSTRAINT [FK_AutoReminderRegions_Region]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_AutoReminderReportMessageTemplates_Report]') AND parent_object_id = OBJECT_ID(N'[dbo].[AutoReminderReportMessageTemplates]'))
ALTER TABLE [dbo].[AutoReminderReportMessageTemplates]  WITH CHECK ADD  CONSTRAINT [FK_AutoReminderReportMessageTemplates_Report] FOREIGN KEY([ReportId])
REFERENCES [dbo].[Report] ([RepID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_AutoReminderReportMessageTemplates_Report]') AND parent_object_id = OBJECT_ID(N'[dbo].[AutoReminderReportMessageTemplates]'))
ALTER TABLE [dbo].[AutoReminderReportMessageTemplates] CHECK CONSTRAINT [FK_AutoReminderReportMessageTemplates_Report]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategorizingQueries_Queries]') AND parent_object_id = OBJECT_ID(N'[dbo].[CategorizingQueries]'))
ALTER TABLE [dbo].[CategorizingQueries]  WITH CHECK ADD  CONSTRAINT [FK_CategorizingQueries_Queries] FOREIGN KEY([QueryID])
REFERENCES [dbo].[Queries] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategorizingQueries_Queries]') AND parent_object_id = OBJECT_ID(N'[dbo].[CategorizingQueries]'))
ALTER TABLE [dbo].[CategorizingQueries] CHECK CONSTRAINT [FK_CategorizingQueries_Queries]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategorizingQueries_QueryCategories]') AND parent_object_id = OBJECT_ID(N'[dbo].[CategorizingQueries]'))
ALTER TABLE [dbo].[CategorizingQueries]  WITH CHECK ADD  CONSTRAINT [FK_CategorizingQueries_QueryCategories] FOREIGN KEY([QueryCategoryID])
REFERENCES [dbo].[QueryCategories] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategorizingQueries_QueryCategories]') AND parent_object_id = OBJECT_ID(N'[dbo].[CategorizingQueries]'))
ALTER TABLE [dbo].[CategorizingQueries] CHECK CONSTRAINT [FK_CategorizingQueries_QueryCategories]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.CategorizingQueries_dbo.Queries_QueryID]') AND parent_object_id = OBJECT_ID(N'[dbo].[CategorizingQueries]'))
ALTER TABLE [dbo].[CategorizingQueries]  WITH CHECK ADD  CONSTRAINT [FK_dbo.CategorizingQueries_dbo.Queries_QueryID] FOREIGN KEY([QueryID])
REFERENCES [dbo].[Queries] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.CategorizingQueries_dbo.Queries_QueryID]') AND parent_object_id = OBJECT_ID(N'[dbo].[CategorizingQueries]'))
ALTER TABLE [dbo].[CategorizingQueries] CHECK CONSTRAINT [FK_dbo.CategorizingQueries_dbo.Queries_QueryID]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.CDCTargets_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[CDCTargets]'))
ALTER TABLE [dbo].[CDCTargets]  WITH CHECK ADD  CONSTRAINT [FK_dbo.CDCTargets_dbo.Facilities_FacilityCode] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.CDCTargets_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[CDCTargets]'))
ALTER TABLE [dbo].[CDCTargets] CHECK CONSTRAINT [FK_dbo.CDCTargets_dbo.Facilities_FacilityCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.CDCTargets1_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[CDCTargets1]'))
ALTER TABLE [dbo].[CDCTargets1]  WITH CHECK ADD  CONSTRAINT [FK_dbo.CDCTargets1_dbo.Facilities_FacilityCode] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.CDCTargets1_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[CDCTargets1]'))
ALTER TABLE [dbo].[CDCTargets1] CHECK CONSTRAINT [FK_dbo.CDCTargets1_dbo.Facilities_FacilityCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.CDCTargetsDemo_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[CDCTargetsDemo]'))
ALTER TABLE [dbo].[CDCTargetsDemo]  WITH CHECK ADD  CONSTRAINT [FK_dbo.CDCTargetsDemo_dbo.Facilities_FacilityCode] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.CDCTargetsDemo_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[CDCTargetsDemo]'))
ALTER TABLE [dbo].[CDCTargetsDemo] CHECK CONSTRAINT [FK_dbo.CDCTargetsDemo_dbo.Facilities_FacilityCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_District_Region]') AND parent_object_id = OBJECT_ID(N'[dbo].[District]'))
ALTER TABLE [dbo].[District]  WITH CHECK ADD  CONSTRAINT [FK_District_Region] FOREIGN KEY([RegionNo])
REFERENCES [dbo].[Region] ([RegionNo])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_District_Region]') AND parent_object_id = OBJECT_ID(N'[dbo].[District]'))
ALTER TABLE [dbo].[District] CHECK CONSTRAINT [FK_District_Region]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ErrMsgSMS_dbo.KnownReportingErrors_KnownReportingErrorId]') AND parent_object_id = OBJECT_ID(N'[dbo].[ErrMsgSMS]'))
ALTER TABLE [dbo].[ErrMsgSMS]  WITH CHECK ADD  CONSTRAINT [FK_dbo.ErrMsgSMS_dbo.KnownReportingErrors_KnownReportingErrorId] FOREIGN KEY([KnownReportingErrorId])
REFERENCES [dbo].[KnownReportingErrors] ([ErrorCode])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ErrMsgSMS_dbo.KnownReportingErrors_KnownReportingErrorId]') AND parent_object_id = OBJECT_ID(N'[dbo].[ErrMsgSMS]'))
ALTER TABLE [dbo].[ErrMsgSMS] CHECK CONSTRAINT [FK_dbo.ErrMsgSMS_dbo.KnownReportingErrors_KnownReportingErrorId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ExcelTemplateCellAssociations_dbo.ExcelTemplateCells_CellId_1]') AND parent_object_id = OBJECT_ID(N'[dbo].[ExcelTemplateCellAssociations]'))
ALTER TABLE [dbo].[ExcelTemplateCellAssociations]  WITH CHECK ADD  CONSTRAINT [FK_dbo.ExcelTemplateCellAssociations_dbo.ExcelTemplateCells_CellId_1] FOREIGN KEY([CellId_1])
REFERENCES [dbo].[ExcelTemplateCells] ([CellID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ExcelTemplateCellAssociations_dbo.ExcelTemplateCells_CellId_1]') AND parent_object_id = OBJECT_ID(N'[dbo].[ExcelTemplateCellAssociations]'))
ALTER TABLE [dbo].[ExcelTemplateCellAssociations] CHECK CONSTRAINT [FK_dbo.ExcelTemplateCellAssociations_dbo.ExcelTemplateCells_CellId_1]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ExcelTemplateCellAssociations_dbo.ExcelTemplateCells_CellId_2]') AND parent_object_id = OBJECT_ID(N'[dbo].[ExcelTemplateCellAssociations]'))
ALTER TABLE [dbo].[ExcelTemplateCellAssociations]  WITH CHECK ADD  CONSTRAINT [FK_dbo.ExcelTemplateCellAssociations_dbo.ExcelTemplateCells_CellId_2] FOREIGN KEY([CellId_2])
REFERENCES [dbo].[ExcelTemplateCells] ([CellID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ExcelTemplateCellAssociations_dbo.ExcelTemplateCells_CellId_2]') AND parent_object_id = OBJECT_ID(N'[dbo].[ExcelTemplateCellAssociations]'))
ALTER TABLE [dbo].[ExcelTemplateCellAssociations] CHECK CONSTRAINT [FK_dbo.ExcelTemplateCellAssociations_dbo.ExcelTemplateCells_CellId_2]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ExcelTemplateCellExtras_dbo.ExcelTemplateCells_CellID]') AND parent_object_id = OBJECT_ID(N'[dbo].[ExcelTemplateCellExtras]'))
ALTER TABLE [dbo].[ExcelTemplateCellExtras]  WITH CHECK ADD  CONSTRAINT [FK_dbo.ExcelTemplateCellExtras_dbo.ExcelTemplateCells_CellID] FOREIGN KEY([CellID])
REFERENCES [dbo].[ExcelTemplateCells] ([CellID])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ExcelTemplateCellExtras_dbo.ExcelTemplateCells_CellID]') AND parent_object_id = OBJECT_ID(N'[dbo].[ExcelTemplateCellExtras]'))
ALTER TABLE [dbo].[ExcelTemplateCellExtras] CHECK CONSTRAINT [FK_dbo.ExcelTemplateCellExtras_dbo.ExcelTemplateCells_CellID]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ExcelTemplateCells_dbo.ExcelTemplateSheets_SheetID]') AND parent_object_id = OBJECT_ID(N'[dbo].[ExcelTemplateCells]'))
ALTER TABLE [dbo].[ExcelTemplateCells]  WITH CHECK ADD  CONSTRAINT [FK_dbo.ExcelTemplateCells_dbo.ExcelTemplateSheets_SheetID] FOREIGN KEY([SheetID])
REFERENCES [dbo].[ExcelTemplateSheets] ([SheetID])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ExcelTemplateCells_dbo.ExcelTemplateSheets_SheetID]') AND parent_object_id = OBJECT_ID(N'[dbo].[ExcelTemplateCells]'))
ALTER TABLE [dbo].[ExcelTemplateCells] CHECK CONSTRAINT [FK_dbo.ExcelTemplateCells_dbo.ExcelTemplateSheets_SheetID]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ExcelTemplateSheets_dbo.ExcelTemplateReport_TemplateID]') AND parent_object_id = OBJECT_ID(N'[dbo].[ExcelTemplateSheets]'))
ALTER TABLE [dbo].[ExcelTemplateSheets]  WITH CHECK ADD  CONSTRAINT [FK_dbo.ExcelTemplateSheets_dbo.ExcelTemplateReport_TemplateID] FOREIGN KEY([TemplateID])
REFERENCES [dbo].[ExcelTemplateReport] ([TemplateID])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ExcelTemplateSheets_dbo.ExcelTemplateReport_TemplateID]') AND parent_object_id = OBJECT_ID(N'[dbo].[ExcelTemplateSheets]'))
ALTER TABLE [dbo].[ExcelTemplateSheets] CHECK CONSTRAINT [FK_dbo.ExcelTemplateSheets_dbo.ExcelTemplateReport_TemplateID]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ExpectedReports_Facilities]') AND parent_object_id = OBJECT_ID(N'[dbo].[ExpectedReports]'))
ALTER TABLE [dbo].[ExpectedReports]  WITH CHECK ADD  CONSTRAINT [FK_ExpectedReports_Facilities] FOREIGN KEY([FacCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ExpectedReports_Facilities]') AND parent_object_id = OBJECT_ID(N'[dbo].[ExpectedReports]'))
ALTER TABLE [dbo].[ExpectedReports] CHECK CONSTRAINT [FK_ExpectedReports_Facilities]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ExpectedReports_Report]') AND parent_object_id = OBJECT_ID(N'[dbo].[ExpectedReports]'))
ALTER TABLE [dbo].[ExpectedReports]  WITH CHECK ADD  CONSTRAINT [FK_ExpectedReports_Report] FOREIGN KEY([ReportID])
REFERENCES [dbo].[Report] ([RepID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ExpectedReports_Report]') AND parent_object_id = OBJECT_ID(N'[dbo].[ExpectedReports]'))
ALTER TABLE [dbo].[ExpectedReports] CHECK CONSTRAINT [FK_ExpectedReports_Report]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.Facilities_dbo.Region_Region]') AND parent_object_id = OBJECT_ID(N'[dbo].[Facilities]'))
ALTER TABLE [dbo].[Facilities]  WITH CHECK ADD  CONSTRAINT [FK_dbo.Facilities_dbo.Region_Region] FOREIGN KEY([Region])
REFERENCES [dbo].[Region] ([RegionNo])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.Facilities_dbo.Region_Region]') AND parent_object_id = OBJECT_ID(N'[dbo].[Facilities]'))
ALTER TABLE [dbo].[Facilities] CHECK CONSTRAINT [FK_dbo.Facilities_dbo.Region_Region]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Facilities_District]') AND parent_object_id = OBJECT_ID(N'[dbo].[Facilities]'))
ALTER TABLE [dbo].[Facilities]  WITH CHECK ADD  CONSTRAINT [FK_Facilities_District] FOREIGN KEY([District])
REFERENCES [dbo].[District] ([DistrictNo])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Facilities_District]') AND parent_object_id = OBJECT_ID(N'[dbo].[Facilities]'))
ALTER TABLE [dbo].[Facilities] CHECK CONSTRAINT [FK_Facilities_District]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Facilities_FacilityType]') AND parent_object_id = OBJECT_ID(N'[dbo].[Facilities]'))
ALTER TABLE [dbo].[Facilities]  WITH CHECK ADD  CONSTRAINT [FK_Facilities_FacilityType] FOREIGN KEY([FacilityType])
REFERENCES [dbo].[FacilityType] ([TypeId])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Facilities_FacilityType]') AND parent_object_id = OBJECT_ID(N'[dbo].[Facilities]'))
ALTER TABLE [dbo].[Facilities] CHECK CONSTRAINT [FK_Facilities_FacilityType]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Facilities_SupportingPartners]') AND parent_object_id = OBJECT_ID(N'[dbo].[Facilities]'))
ALTER TABLE [dbo].[Facilities]  WITH CHECK ADD  CONSTRAINT [FK_Facilities_SupportingPartners] FOREIGN KEY([SupportingPartnerId])
REFERENCES [dbo].[SupportingPartners] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Facilities_SupportingPartners]') AND parent_object_id = OBJECT_ID(N'[dbo].[Facilities]'))
ALTER TABLE [dbo].[Facilities] CHECK CONSTRAINT [FK_Facilities_SupportingPartners]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_EmOC_dbo.ANCFormMetadata_MetadataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_EmOC]'))
ALTER TABLE [dbo].[LDForm_EmOC]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForm_EmOC_dbo.ANCFormMetadata_MetadataId] FOREIGN KEY([MetadataId])
REFERENCES [dbo].[ANCFormMetadata] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_EmOC_dbo.ANCFormMetadata_MetadataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_EmOC]'))
ALTER TABLE [dbo].[LDForm_EmOC] CHECK CONSTRAINT [FK_dbo.LDForm_EmOC_dbo.ANCFormMetadata_MetadataId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_EmOC_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_EmOC]'))
ALTER TABLE [dbo].[LDForm_EmOC]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForm_EmOC_dbo.Facilities_FacilityCode] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_EmOC_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_EmOC]'))
ALTER TABLE [dbo].[LDForm_EmOC] CHECK CONSTRAINT [FK_dbo.LDForm_EmOC_dbo.Facilities_FacilityCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_MatatizoBaadaYaKujifungua_dbo.ANCFormMetadata_MetadataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_MatatizoBaadaYaKujifungua]'))
ALTER TABLE [dbo].[LDForm_MatatizoBaadaYaKujifungua]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForm_MatatizoBaadaYaKujifungua_dbo.ANCFormMetadata_MetadataId] FOREIGN KEY([MetadataId])
REFERENCES [dbo].[ANCFormMetadata] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_MatatizoBaadaYaKujifungua_dbo.ANCFormMetadata_MetadataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_MatatizoBaadaYaKujifungua]'))
ALTER TABLE [dbo].[LDForm_MatatizoBaadaYaKujifungua] CHECK CONSTRAINT [FK_dbo.LDForm_MatatizoBaadaYaKujifungua_dbo.ANCFormMetadata_MetadataId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_MatatizoBaadaYaKujifungua_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_MatatizoBaadaYaKujifungua]'))
ALTER TABLE [dbo].[LDForm_MatatizoBaadaYaKujifungua]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForm_MatatizoBaadaYaKujifungua_dbo.Facilities_FacilityCode] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_MatatizoBaadaYaKujifungua_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_MatatizoBaadaYaKujifungua]'))
ALTER TABLE [dbo].[LDForm_MatatizoBaadaYaKujifungua] CHECK CONSTRAINT [FK_dbo.LDForm_MatatizoBaadaYaKujifungua_dbo.Facilities_FacilityCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_MatatizoKablaYaKujifungua_dbo.ANCFormMetadata_MetadataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_MatatizoKablaYaKujifungua]'))
ALTER TABLE [dbo].[LDForm_MatatizoKablaYaKujifungua]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForm_MatatizoKablaYaKujifungua_dbo.ANCFormMetadata_MetadataId] FOREIGN KEY([MetadataId])
REFERENCES [dbo].[ANCFormMetadata] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_MatatizoKablaYaKujifungua_dbo.ANCFormMetadata_MetadataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_MatatizoKablaYaKujifungua]'))
ALTER TABLE [dbo].[LDForm_MatatizoKablaYaKujifungua] CHECK CONSTRAINT [FK_dbo.LDForm_MatatizoKablaYaKujifungua_dbo.ANCFormMetadata_MetadataId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_MatatizoKablaYaKujifungua_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_MatatizoKablaYaKujifungua]'))
ALTER TABLE [dbo].[LDForm_MatatizoKablaYaKujifungua]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForm_MatatizoKablaYaKujifungua_dbo.Facilities_FacilityCode] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_MatatizoKablaYaKujifungua_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_MatatizoKablaYaKujifungua]'))
ALTER TABLE [dbo].[LDForm_MatatizoKablaYaKujifungua] CHECK CONSTRAINT [FK_dbo.LDForm_MatatizoKablaYaKujifungua_dbo.Facilities_FacilityCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_NjiaYaKujifungua_dbo.ANCFormMetadata_MetadataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_NjiaYaKujifungua]'))
ALTER TABLE [dbo].[LDForm_NjiaYaKujifungua]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForm_NjiaYaKujifungua_dbo.ANCFormMetadata_MetadataId] FOREIGN KEY([MetadataId])
REFERENCES [dbo].[ANCFormMetadata] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_NjiaYaKujifungua_dbo.ANCFormMetadata_MetadataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_NjiaYaKujifungua]'))
ALTER TABLE [dbo].[LDForm_NjiaYaKujifungua] CHECK CONSTRAINT [FK_dbo.LDForm_NjiaYaKujifungua_dbo.ANCFormMetadata_MetadataId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_NjiaYaKujifungua_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_NjiaYaKujifungua]'))
ALTER TABLE [dbo].[LDForm_NjiaYaKujifungua]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForm_NjiaYaKujifungua_dbo.Facilities_FacilityCode] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_NjiaYaKujifungua_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_NjiaYaKujifungua]'))
ALTER TABLE [dbo].[LDForm_NjiaYaKujifungua] CHECK CONSTRAINT [FK_dbo.LDForm_NjiaYaKujifungua_dbo.Facilities_FacilityCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_PMTCT_dbo.ANCFormMetadata_MetadataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_PMTCT]'))
ALTER TABLE [dbo].[LDForm_PMTCT]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForm_PMTCT_dbo.ANCFormMetadata_MetadataId] FOREIGN KEY([MetadataId])
REFERENCES [dbo].[ANCFormMetadata] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_PMTCT_dbo.ANCFormMetadata_MetadataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_PMTCT]'))
ALTER TABLE [dbo].[LDForm_PMTCT] CHECK CONSTRAINT [FK_dbo.LDForm_PMTCT_dbo.ANCFormMetadata_MetadataId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_PMTCT_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_PMTCT]'))
ALTER TABLE [dbo].[LDForm_PMTCT]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForm_PMTCT_dbo.Facilities_FacilityCode] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_PMTCT_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_PMTCT]'))
ALTER TABLE [dbo].[LDForm_PMTCT] CHECK CONSTRAINT [FK_dbo.LDForm_PMTCT_dbo.Facilities_FacilityCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_TaarifaYaWaliojifungua_dbo.ANCFormMetadata_MetadataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_TaarifaYaWaliojifungua]'))
ALTER TABLE [dbo].[LDForm_TaarifaYaWaliojifungua]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForm_TaarifaYaWaliojifungua_dbo.ANCFormMetadata_MetadataId] FOREIGN KEY([MetadataId])
REFERENCES [dbo].[ANCFormMetadata] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_TaarifaYaWaliojifungua_dbo.ANCFormMetadata_MetadataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_TaarifaYaWaliojifungua]'))
ALTER TABLE [dbo].[LDForm_TaarifaYaWaliojifungua] CHECK CONSTRAINT [FK_dbo.LDForm_TaarifaYaWaliojifungua_dbo.ANCFormMetadata_MetadataId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_TaarifaYaWaliojifungua_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_TaarifaYaWaliojifungua]'))
ALTER TABLE [dbo].[LDForm_TaarifaYaWaliojifungua]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForm_TaarifaYaWaliojifungua_dbo.Facilities_FacilityCode] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_TaarifaYaWaliojifungua_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_TaarifaYaWaliojifungua]'))
ALTER TABLE [dbo].[LDForm_TaarifaYaWaliojifungua] CHECK CONSTRAINT [FK_dbo.LDForm_TaarifaYaWaliojifungua_dbo.Facilities_FacilityCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_WatotoWaliosaidiwaKupumua_dbo.ANCFormMetadata_MetadataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_WatotoWaliosaidiwaKupumua]'))
ALTER TABLE [dbo].[LDForm_WatotoWaliosaidiwaKupumua]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForm_WatotoWaliosaidiwaKupumua_dbo.ANCFormMetadata_MetadataId] FOREIGN KEY([MetadataId])
REFERENCES [dbo].[ANCFormMetadata] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_WatotoWaliosaidiwaKupumua_dbo.ANCFormMetadata_MetadataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_WatotoWaliosaidiwaKupumua]'))
ALTER TABLE [dbo].[LDForm_WatotoWaliosaidiwaKupumua] CHECK CONSTRAINT [FK_dbo.LDForm_WatotoWaliosaidiwaKupumua_dbo.ANCFormMetadata_MetadataId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_WatotoWaliosaidiwaKupumua_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_WatotoWaliosaidiwaKupumua]'))
ALTER TABLE [dbo].[LDForm_WatotoWaliosaidiwaKupumua]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForm_WatotoWaliosaidiwaKupumua_dbo.Facilities_FacilityCode] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_WatotoWaliosaidiwaKupumua_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_WatotoWaliosaidiwaKupumua]'))
ALTER TABLE [dbo].[LDForm_WatotoWaliosaidiwaKupumua] CHECK CONSTRAINT [FK_dbo.LDForm_WatotoWaliosaidiwaKupumua_dbo.Facilities_FacilityCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_WatotoWaliozaliwaMapacha_dbo.ANCFormMetadata_MetadataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_WatotoWaliozaliwaMapacha]'))
ALTER TABLE [dbo].[LDForm_WatotoWaliozaliwaMapacha]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForm_WatotoWaliozaliwaMapacha_dbo.ANCFormMetadata_MetadataId] FOREIGN KEY([MetadataId])
REFERENCES [dbo].[ANCFormMetadata] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_WatotoWaliozaliwaMapacha_dbo.ANCFormMetadata_MetadataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_WatotoWaliozaliwaMapacha]'))
ALTER TABLE [dbo].[LDForm_WatotoWaliozaliwaMapacha] CHECK CONSTRAINT [FK_dbo.LDForm_WatotoWaliozaliwaMapacha_dbo.ANCFormMetadata_MetadataId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_WatotoWaliozaliwaMapacha_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_WatotoWaliozaliwaMapacha]'))
ALTER TABLE [dbo].[LDForm_WatotoWaliozaliwaMapacha]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForm_WatotoWaliozaliwaMapacha_dbo.Facilities_FacilityCode] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_WatotoWaliozaliwaMapacha_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_WatotoWaliozaliwaMapacha]'))
ALTER TABLE [dbo].[LDForm_WatotoWaliozaliwaMapacha] CHECK CONSTRAINT [FK_dbo.LDForm_WatotoWaliozaliwaMapacha_dbo.Facilities_FacilityCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_WatotoWaliozaliwaMmoja_dbo.ANCFormMetadata_MetadataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_WatotoWaliozaliwaMmoja]'))
ALTER TABLE [dbo].[LDForm_WatotoWaliozaliwaMmoja]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForm_WatotoWaliozaliwaMmoja_dbo.ANCFormMetadata_MetadataId] FOREIGN KEY([MetadataId])
REFERENCES [dbo].[ANCFormMetadata] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_WatotoWaliozaliwaMmoja_dbo.ANCFormMetadata_MetadataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_WatotoWaliozaliwaMmoja]'))
ALTER TABLE [dbo].[LDForm_WatotoWaliozaliwaMmoja] CHECK CONSTRAINT [FK_dbo.LDForm_WatotoWaliozaliwaMmoja_dbo.ANCFormMetadata_MetadataId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_WatotoWaliozaliwaMmoja_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_WatotoWaliozaliwaMmoja]'))
ALTER TABLE [dbo].[LDForm_WatotoWaliozaliwaMmoja]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForm_WatotoWaliozaliwaMmoja_dbo.Facilities_FacilityCode] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForm_WatotoWaliozaliwaMmoja_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForm_WatotoWaliozaliwaMmoja]'))
ALTER TABLE [dbo].[LDForm_WatotoWaliozaliwaMmoja] CHECK CONSTRAINT [FK_dbo.LDForm_WatotoWaliozaliwaMmoja_dbo.Facilities_FacilityCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForms_dbo.ANCFormMetadata_MetadataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForms]'))
ALTER TABLE [dbo].[LDForms]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForms_dbo.ANCFormMetadata_MetadataId] FOREIGN KEY([MetadataId])
REFERENCES [dbo].[ANCFormMetadata] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForms_dbo.ANCFormMetadata_MetadataId]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForms]'))
ALTER TABLE [dbo].[LDForms] CHECK CONSTRAINT [FK_dbo.LDForms_dbo.ANCFormMetadata_MetadataId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForms_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForms]'))
ALTER TABLE [dbo].[LDForms]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForms_dbo.Facilities_FacilityCode] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForms_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForms]'))
ALTER TABLE [dbo].[LDForms] CHECK CONSTRAINT [FK_dbo.LDForms_dbo.Facilities_FacilityCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForms_dbo.LDForm_EmOC_EmOC_7id]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForms]'))
ALTER TABLE [dbo].[LDForms]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForms_dbo.LDForm_EmOC_EmOC_7id] FOREIGN KEY([EmOC_7id])
REFERENCES [dbo].[LDForm_EmOC] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForms_dbo.LDForm_EmOC_EmOC_7id]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForms]'))
ALTER TABLE [dbo].[LDForms] CHECK CONSTRAINT [FK_dbo.LDForms_dbo.LDForm_EmOC_EmOC_7id]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForms_dbo.LDForm_MatatizoBaadaYaKujifungua_MatatizoBaadaYaKujifungua_6id]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForms]'))
ALTER TABLE [dbo].[LDForms]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForms_dbo.LDForm_MatatizoBaadaYaKujifungua_MatatizoBaadaYaKujifungua_6id] FOREIGN KEY([MatatizoBaadaYaKujifungua_6id])
REFERENCES [dbo].[LDForm_MatatizoBaadaYaKujifungua] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForms_dbo.LDForm_MatatizoBaadaYaKujifungua_MatatizoBaadaYaKujifungua_6id]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForms]'))
ALTER TABLE [dbo].[LDForms] CHECK CONSTRAINT [FK_dbo.LDForms_dbo.LDForm_MatatizoBaadaYaKujifungua_MatatizoBaadaYaKujifungua_6id]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForms_dbo.LDForm_MatatizoKablaYaKujifungua_MatatizoKablaYaKujifungua_4id]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForms]'))
ALTER TABLE [dbo].[LDForms]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForms_dbo.LDForm_MatatizoKablaYaKujifungua_MatatizoKablaYaKujifungua_4id] FOREIGN KEY([MatatizoKablaYaKujifungua_4id])
REFERENCES [dbo].[LDForm_MatatizoKablaYaKujifungua] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForms_dbo.LDForm_MatatizoKablaYaKujifungua_MatatizoKablaYaKujifungua_4id]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForms]'))
ALTER TABLE [dbo].[LDForms] CHECK CONSTRAINT [FK_dbo.LDForms_dbo.LDForm_MatatizoKablaYaKujifungua_MatatizoKablaYaKujifungua_4id]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForms_dbo.LDForm_NjiaYaKujifungua_NjiaYaKujifungua_3id]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForms]'))
ALTER TABLE [dbo].[LDForms]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForms_dbo.LDForm_NjiaYaKujifungua_NjiaYaKujifungua_3id] FOREIGN KEY([NjiaYaKujifungua_3id])
REFERENCES [dbo].[LDForm_NjiaYaKujifungua] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForms_dbo.LDForm_NjiaYaKujifungua_NjiaYaKujifungua_3id]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForms]'))
ALTER TABLE [dbo].[LDForms] CHECK CONSTRAINT [FK_dbo.LDForms_dbo.LDForm_NjiaYaKujifungua_NjiaYaKujifungua_3id]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForms_dbo.LDForm_PMTCT_PMTCT_8id]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForms]'))
ALTER TABLE [dbo].[LDForms]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForms_dbo.LDForm_PMTCT_PMTCT_8id] FOREIGN KEY([PMTCT_8id])
REFERENCES [dbo].[LDForm_PMTCT] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForms_dbo.LDForm_PMTCT_PMTCT_8id]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForms]'))
ALTER TABLE [dbo].[LDForms] CHECK CONSTRAINT [FK_dbo.LDForms_dbo.LDForm_PMTCT_PMTCT_8id]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForms_dbo.LDForm_TaarifaYaWaliojifungua_TaarifaYaWaliojifungua_2id]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForms]'))
ALTER TABLE [dbo].[LDForms]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForms_dbo.LDForm_TaarifaYaWaliojifungua_TaarifaYaWaliojifungua_2id] FOREIGN KEY([TaarifaYaWaliojifungua_2id])
REFERENCES [dbo].[LDForm_TaarifaYaWaliojifungua] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForms_dbo.LDForm_TaarifaYaWaliojifungua_TaarifaYaWaliojifungua_2id]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForms]'))
ALTER TABLE [dbo].[LDForms] CHECK CONSTRAINT [FK_dbo.LDForms_dbo.LDForm_TaarifaYaWaliojifungua_TaarifaYaWaliojifungua_2id]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForms_dbo.LDForm_WatotoWaliosaidiwaKupumua_WatotoWaliosaidiwaKupumua_11id]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForms]'))
ALTER TABLE [dbo].[LDForms]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForms_dbo.LDForm_WatotoWaliosaidiwaKupumua_WatotoWaliosaidiwaKupumua_11id] FOREIGN KEY([WatotoWaliosaidiwaKupumua_11id])
REFERENCES [dbo].[LDForm_WatotoWaliosaidiwaKupumua] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForms_dbo.LDForm_WatotoWaliosaidiwaKupumua_WatotoWaliosaidiwaKupumua_11id]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForms]'))
ALTER TABLE [dbo].[LDForms] CHECK CONSTRAINT [FK_dbo.LDForms_dbo.LDForm_WatotoWaliosaidiwaKupumua_WatotoWaliosaidiwaKupumua_11id]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForms_dbo.LDForm_WatotoWaliozaliwaMapacha_WatotoWaliozaliwaMapacha_10id]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForms]'))
ALTER TABLE [dbo].[LDForms]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForms_dbo.LDForm_WatotoWaliozaliwaMapacha_WatotoWaliozaliwaMapacha_10id] FOREIGN KEY([WatotoWaliozaliwaMapacha_10id])
REFERENCES [dbo].[LDForm_WatotoWaliozaliwaMapacha] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForms_dbo.LDForm_WatotoWaliozaliwaMapacha_WatotoWaliozaliwaMapacha_10id]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForms]'))
ALTER TABLE [dbo].[LDForms] CHECK CONSTRAINT [FK_dbo.LDForms_dbo.LDForm_WatotoWaliozaliwaMapacha_WatotoWaliozaliwaMapacha_10id]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForms_dbo.LDForm_WatotoWaliozaliwaMmoja_WatotoWaliozaliwaMmoja_9id]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForms]'))
ALTER TABLE [dbo].[LDForms]  WITH CHECK ADD  CONSTRAINT [FK_dbo.LDForms_dbo.LDForm_WatotoWaliozaliwaMmoja_WatotoWaliozaliwaMmoja_9id] FOREIGN KEY([WatotoWaliozaliwaMmoja_9id])
REFERENCES [dbo].[LDForm_WatotoWaliozaliwaMmoja] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.LDForms_dbo.LDForm_WatotoWaliozaliwaMmoja_WatotoWaliozaliwaMmoja_9id]') AND parent_object_id = OBJECT_ID(N'[dbo].[LDForms]'))
ALTER TABLE [dbo].[LDForms] CHECK CONSTRAINT [FK_dbo.LDForms_dbo.LDForm_WatotoWaliozaliwaMmoja_WatotoWaliozaliwaMmoja_9id]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.MessagingLogs_dbo.OtherSystemUserNumbers_PhoneNumber]') AND parent_object_id = OBJECT_ID(N'[dbo].[MessagingLogs]'))
ALTER TABLE [dbo].[MessagingLogs]  WITH CHECK ADD  CONSTRAINT [FK_dbo.MessagingLogs_dbo.OtherSystemUserNumbers_PhoneNumber] FOREIGN KEY([PhoneNumber])
REFERENCES [dbo].[OtherSystemUserNumbers] ([PhoneNumber])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.MessagingLogs_dbo.OtherSystemUserNumbers_PhoneNumber]') AND parent_object_id = OBJECT_ID(N'[dbo].[MessagingLogs]'))
ALTER TABLE [dbo].[MessagingLogs] CHECK CONSTRAINT [FK_dbo.MessagingLogs_dbo.OtherSystemUserNumbers_PhoneNumber]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MobilePhoneOperators_MobileContryCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[MobilePhoneOperators]'))
ALTER TABLE [dbo].[MobilePhoneOperators]  WITH CHECK ADD  CONSTRAINT [FK_MobilePhoneOperators_MobileContryCode] FOREIGN KEY([MCC])
REFERENCES [dbo].[MobileContryCode] ([MCC])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MobilePhoneOperators_MobileContryCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[MobilePhoneOperators]'))
ALTER TABLE [dbo].[MobilePhoneOperators] CHECK CONSTRAINT [FK_MobilePhoneOperators_MobileContryCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ModemAssociatedCellNumbers_ModemSettings]') AND parent_object_id = OBJECT_ID(N'[dbo].[ModemAssociatedCellNumbers]'))
ALTER TABLE [dbo].[ModemAssociatedCellNumbers]  WITH CHECK ADD  CONSTRAINT [FK_ModemAssociatedCellNumbers_ModemSettings] FOREIGN KEY([ModemSettingNo])
REFERENCES [dbo].[ModemSettings] ([ModemSettingNo])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ModemAssociatedCellNumbers_ModemSettings]') AND parent_object_id = OBJECT_ID(N'[dbo].[ModemAssociatedCellNumbers]'))
ALTER TABLE [dbo].[ModemAssociatedCellNumbers] CHECK CONSTRAINT [FK_ModemAssociatedCellNumbers_ModemSettings]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MTUHA_ReportSectionDetails_MTUHA_ReportSections]') AND parent_object_id = OBJECT_ID(N'[dbo].[MTUHA_ReportSectionDetails]'))
ALTER TABLE [dbo].[MTUHA_ReportSectionDetails]  WITH CHECK ADD  CONSTRAINT [FK_MTUHA_ReportSectionDetails_MTUHA_ReportSections] FOREIGN KEY([SectionId])
REFERENCES [dbo].[MTUHA_ReportSections] ([SectionId])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MTUHA_ReportSectionDetails_MTUHA_ReportSections]') AND parent_object_id = OBJECT_ID(N'[dbo].[MTUHA_ReportSectionDetails]'))
ALTER TABLE [dbo].[MTUHA_ReportSectionDetails] CHECK CONSTRAINT [FK_MTUHA_ReportSectionDetails_MTUHA_ReportSections]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MTUHA_ReportSections_MTUHA_Reports]') AND parent_object_id = OBJECT_ID(N'[dbo].[MTUHA_ReportSections]'))
ALTER TABLE [dbo].[MTUHA_ReportSections]  WITH CHECK ADD  CONSTRAINT [FK_MTUHA_ReportSections_MTUHA_Reports] FOREIGN KEY([MTUHAReportId])
REFERENCES [dbo].[MTUHA_Reports] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MTUHA_ReportSections_MTUHA_Reports]') AND parent_object_id = OBJECT_ID(N'[dbo].[MTUHA_ReportSections]'))
ALTER TABLE [dbo].[MTUHA_ReportSections] CHECK CONSTRAINT [FK_MTUHA_ReportSections_MTUHA_Reports]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.OfflineReportIndicators_dbo.OfflineReports_OfflineReport_Id]') AND parent_object_id = OBJECT_ID(N'[dbo].[OfflineReportIndicators]'))
ALTER TABLE [dbo].[OfflineReportIndicators]  WITH CHECK ADD  CONSTRAINT [FK_dbo.OfflineReportIndicators_dbo.OfflineReports_OfflineReport_Id] FOREIGN KEY([OfflineReport_Id])
REFERENCES [dbo].[OfflineReports] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.OfflineReportIndicators_dbo.OfflineReports_OfflineReport_Id]') AND parent_object_id = OBJECT_ID(N'[dbo].[OfflineReportIndicators]'))
ALTER TABLE [dbo].[OfflineReportIndicators] CHECK CONSTRAINT [FK_dbo.OfflineReportIndicators_dbo.OfflineReports_OfflineReport_Id]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.OfflineReports_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[OfflineReports]'))
ALTER TABLE [dbo].[OfflineReports]  WITH CHECK ADD  CONSTRAINT [FK_dbo.OfflineReports_dbo.Facilities_FacilityCode] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.OfflineReports_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[OfflineReports]'))
ALTER TABLE [dbo].[OfflineReports] CHECK CONSTRAINT [FK_dbo.OfflineReports_dbo.Facilities_FacilityCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.OfflineReports_dbo.Report_ReportId]') AND parent_object_id = OBJECT_ID(N'[dbo].[OfflineReports]'))
ALTER TABLE [dbo].[OfflineReports]  WITH CHECK ADD  CONSTRAINT [FK_dbo.OfflineReports_dbo.Report_ReportId] FOREIGN KEY([ReportId])
REFERENCES [dbo].[Report] ([RepID])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.OfflineReports_dbo.Report_ReportId]') AND parent_object_id = OBJECT_ID(N'[dbo].[OfflineReports]'))
ALTER TABLE [dbo].[OfflineReports] CHECK CONSTRAINT [FK_dbo.OfflineReports_dbo.Report_ReportId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.OfflineReports_dbo.Users_CreatedByUserId]') AND parent_object_id = OBJECT_ID(N'[dbo].[OfflineReports]'))
ALTER TABLE [dbo].[OfflineReports]  WITH CHECK ADD  CONSTRAINT [FK_dbo.OfflineReports_dbo.Users_CreatedByUserId] FOREIGN KEY([CreatedByUserId])
REFERENCES [dbo].[Users] ([ID])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.OfflineReports_dbo.Users_CreatedByUserId]') AND parent_object_id = OBJECT_ID(N'[dbo].[OfflineReports]'))
ALTER TABLE [dbo].[OfflineReports] CHECK CONSTRAINT [FK_dbo.OfflineReports_dbo.Users_CreatedByUserId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.OptionBPlusFacilities_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[OptionBPlusFacilities]'))
ALTER TABLE [dbo].[OptionBPlusFacilities]  WITH CHECK ADD  CONSTRAINT [FK_dbo.OptionBPlusFacilities_dbo.Facilities_FacilityCode] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.OptionBPlusFacilities_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[OptionBPlusFacilities]'))
ALTER TABLE [dbo].[OptionBPlusFacilities] CHECK CONSTRAINT [FK_dbo.OptionBPlusFacilities_dbo.Facilities_FacilityCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.OptionBPlusFacilities_dbo.Users_UpdatedByUserId]') AND parent_object_id = OBJECT_ID(N'[dbo].[OptionBPlusFacilities]'))
ALTER TABLE [dbo].[OptionBPlusFacilities]  WITH CHECK ADD  CONSTRAINT [FK_dbo.OptionBPlusFacilities_dbo.Users_UpdatedByUserId] FOREIGN KEY([UpdatedByUserId])
REFERENCES [dbo].[Users] ([ID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.OptionBPlusFacilities_dbo.Users_UpdatedByUserId]') AND parent_object_id = OBJECT_ID(N'[dbo].[OptionBPlusFacilities]'))
ALTER TABLE [dbo].[OptionBPlusFacilities] CHECK CONSTRAINT [FK_dbo.OptionBPlusFacilities_dbo.Users_UpdatedByUserId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.OtherSystemsDistrictDetails_dbo.District_InternalDistrictId]') AND parent_object_id = OBJECT_ID(N'[dbo].[OtherSystemsDistrictDetails]'))
ALTER TABLE [dbo].[OtherSystemsDistrictDetails]  WITH CHECK ADD  CONSTRAINT [FK_dbo.OtherSystemsDistrictDetails_dbo.District_InternalDistrictId] FOREIGN KEY([InternalDistrictId])
REFERENCES [dbo].[District] ([DistrictNo])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.OtherSystemsDistrictDetails_dbo.District_InternalDistrictId]') AND parent_object_id = OBJECT_ID(N'[dbo].[OtherSystemsDistrictDetails]'))
ALTER TABLE [dbo].[OtherSystemsDistrictDetails] CHECK CONSTRAINT [FK_dbo.OtherSystemsDistrictDetails_dbo.District_InternalDistrictId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.OtherSystemsDistrictDetails_dbo.OtherSystems_SystemId]') AND parent_object_id = OBJECT_ID(N'[dbo].[OtherSystemsDistrictDetails]'))
ALTER TABLE [dbo].[OtherSystemsDistrictDetails]  WITH CHECK ADD  CONSTRAINT [FK_dbo.OtherSystemsDistrictDetails_dbo.OtherSystems_SystemId] FOREIGN KEY([SystemId])
REFERENCES [dbo].[OtherSystems] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.OtherSystemsDistrictDetails_dbo.OtherSystems_SystemId]') AND parent_object_id = OBJECT_ID(N'[dbo].[OtherSystemsDistrictDetails]'))
ALTER TABLE [dbo].[OtherSystemsDistrictDetails] CHECK CONSTRAINT [FK_dbo.OtherSystemsDistrictDetails_dbo.OtherSystems_SystemId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OtherSystemsFacilityDetails_Facilities]') AND parent_object_id = OBJECT_ID(N'[dbo].[OtherSystemsFacilityDetails]'))
ALTER TABLE [dbo].[OtherSystemsFacilityDetails]  WITH CHECK ADD  CONSTRAINT [FK_OtherSystemsFacilityDetails_Facilities] FOREIGN KEY([InternalFacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OtherSystemsFacilityDetails_Facilities]') AND parent_object_id = OBJECT_ID(N'[dbo].[OtherSystemsFacilityDetails]'))
ALTER TABLE [dbo].[OtherSystemsFacilityDetails] CHECK CONSTRAINT [FK_OtherSystemsFacilityDetails_Facilities]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OtherSystemsFacilityDetails_OtherSystems]') AND parent_object_id = OBJECT_ID(N'[dbo].[OtherSystemsFacilityDetails]'))
ALTER TABLE [dbo].[OtherSystemsFacilityDetails]  WITH CHECK ADD  CONSTRAINT [FK_OtherSystemsFacilityDetails_OtherSystems] FOREIGN KEY([SystemId])
REFERENCES [dbo].[OtherSystems] ([Id])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OtherSystemsFacilityDetails_OtherSystems]') AND parent_object_id = OBJECT_ID(N'[dbo].[OtherSystemsFacilityDetails]'))
ALTER TABLE [dbo].[OtherSystemsFacilityDetails] CHECK CONSTRAINT [FK_OtherSystemsFacilityDetails_OtherSystems]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.OtherSystemsRegionDetails_dbo.OtherSystems_SystemId]') AND parent_object_id = OBJECT_ID(N'[dbo].[OtherSystemsRegionDetails]'))
ALTER TABLE [dbo].[OtherSystemsRegionDetails]  WITH CHECK ADD  CONSTRAINT [FK_dbo.OtherSystemsRegionDetails_dbo.OtherSystems_SystemId] FOREIGN KEY([SystemId])
REFERENCES [dbo].[OtherSystems] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.OtherSystemsRegionDetails_dbo.OtherSystems_SystemId]') AND parent_object_id = OBJECT_ID(N'[dbo].[OtherSystemsRegionDetails]'))
ALTER TABLE [dbo].[OtherSystemsRegionDetails] CHECK CONSTRAINT [FK_dbo.OtherSystemsRegionDetails_dbo.OtherSystems_SystemId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.OtherSystemsRegionDetails_dbo.Region_InternalRegionId]') AND parent_object_id = OBJECT_ID(N'[dbo].[OtherSystemsRegionDetails]'))
ALTER TABLE [dbo].[OtherSystemsRegionDetails]  WITH CHECK ADD  CONSTRAINT [FK_dbo.OtherSystemsRegionDetails_dbo.Region_InternalRegionId] FOREIGN KEY([InternalRegionId])
REFERENCES [dbo].[Region] ([RegionNo])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.OtherSystemsRegionDetails_dbo.Region_InternalRegionId]') AND parent_object_id = OBJECT_ID(N'[dbo].[OtherSystemsRegionDetails]'))
ALTER TABLE [dbo].[OtherSystemsRegionDetails] CHECK CONSTRAINT [FK_dbo.OtherSystemsRegionDetails_dbo.Region_InternalRegionId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.Queries_dbo.Users_CreatedByUser]') AND parent_object_id = OBJECT_ID(N'[dbo].[Queries]'))
ALTER TABLE [dbo].[Queries]  WITH CHECK ADD  CONSTRAINT [FK_dbo.Queries_dbo.Users_CreatedByUser] FOREIGN KEY([CreatedByUserId])
REFERENCES [dbo].[Users] ([ID])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.Queries_dbo.Users_CreatedByUser]') AND parent_object_id = OBJECT_ID(N'[dbo].[Queries]'))
ALTER TABLE [dbo].[Queries] CHECK CONSTRAINT [FK_dbo.Queries_dbo.Users_CreatedByUser]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.Queries_dbo.Users_DeletedByUser]') AND parent_object_id = OBJECT_ID(N'[dbo].[Queries]'))
ALTER TABLE [dbo].[Queries]  WITH CHECK ADD  CONSTRAINT [FK_dbo.Queries_dbo.Users_DeletedByUser] FOREIGN KEY([DeletedByUserId])
REFERENCES [dbo].[Users] ([ID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.Queries_dbo.Users_DeletedByUser]') AND parent_object_id = OBJECT_ID(N'[dbo].[Queries]'))
ALTER TABLE [dbo].[Queries] CHECK CONSTRAINT [FK_dbo.Queries_dbo.Users_DeletedByUser]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.Queries_dbo.Users_UpdatedByUser]') AND parent_object_id = OBJECT_ID(N'[dbo].[Queries]'))
ALTER TABLE [dbo].[Queries]  WITH CHECK ADD  CONSTRAINT [FK_dbo.Queries_dbo.Users_UpdatedByUser] FOREIGN KEY([UpdatedByUserId])
REFERENCES [dbo].[Users] ([ID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.Queries_dbo.Users_UpdatedByUser]') AND parent_object_id = OBJECT_ID(N'[dbo].[Queries]'))
ALTER TABLE [dbo].[Queries] CHECK CONSTRAINT [FK_dbo.Queries_dbo.Users_UpdatedByUser]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.Queries_dbo.Users_User_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[Queries]'))
ALTER TABLE [dbo].[Queries]  WITH CHECK ADD  CONSTRAINT [FK_dbo.Queries_dbo.Users_User_ID] FOREIGN KEY([User_ID])
REFERENCES [dbo].[Users] ([ID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.Queries_dbo.Users_User_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[Queries]'))
ALTER TABLE [dbo].[Queries] CHECK CONSTRAINT [FK_dbo.Queries_dbo.Users_User_ID]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Queries_QueryType]') AND parent_object_id = OBJECT_ID(N'[dbo].[Queries]'))
ALTER TABLE [dbo].[Queries]  WITH CHECK ADD  CONSTRAINT [FK_Queries_QueryType] FOREIGN KEY([QueryTypeId])
REFERENCES [dbo].[QueryTypes] ([QueryTypeId])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Queries_QueryType]') AND parent_object_id = OBJECT_ID(N'[dbo].[Queries]'))
ALTER TABLE [dbo].[Queries] CHECK CONSTRAINT [FK_Queries_QueryType]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Queries_Users]') AND parent_object_id = OBJECT_ID(N'[dbo].[Queries]'))
ALTER TABLE [dbo].[Queries]  WITH CHECK ADD  CONSTRAINT [FK_Queries_Users] FOREIGN KEY([CreatedByUserId])
REFERENCES [dbo].[Users] ([ID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Queries_Users]') AND parent_object_id = OBJECT_ID(N'[dbo].[Queries]'))
ALTER TABLE [dbo].[Queries] CHECK CONSTRAINT [FK_Queries_Users]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.QueryCategories_dbo.Users_CreatedByUser]') AND parent_object_id = OBJECT_ID(N'[dbo].[QueryCategories]'))
ALTER TABLE [dbo].[QueryCategories]  WITH CHECK ADD  CONSTRAINT [FK_dbo.QueryCategories_dbo.Users_CreatedByUser] FOREIGN KEY([CreatedByUserId])
REFERENCES [dbo].[Users] ([ID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.QueryCategories_dbo.Users_CreatedByUser]') AND parent_object_id = OBJECT_ID(N'[dbo].[QueryCategories]'))
ALTER TABLE [dbo].[QueryCategories] CHECK CONSTRAINT [FK_dbo.QueryCategories_dbo.Users_CreatedByUser]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.QueryCategories_dbo.Users_DeletedByUser]') AND parent_object_id = OBJECT_ID(N'[dbo].[QueryCategories]'))
ALTER TABLE [dbo].[QueryCategories]  WITH CHECK ADD  CONSTRAINT [FK_dbo.QueryCategories_dbo.Users_DeletedByUser] FOREIGN KEY([DeletedByUserId])
REFERENCES [dbo].[Users] ([ID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.QueryCategories_dbo.Users_DeletedByUser]') AND parent_object_id = OBJECT_ID(N'[dbo].[QueryCategories]'))
ALTER TABLE [dbo].[QueryCategories] CHECK CONSTRAINT [FK_dbo.QueryCategories_dbo.Users_DeletedByUser]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.QueryCategories_dbo.Users_UpdatedByUser]') AND parent_object_id = OBJECT_ID(N'[dbo].[QueryCategories]'))
ALTER TABLE [dbo].[QueryCategories]  WITH CHECK ADD  CONSTRAINT [FK_dbo.QueryCategories_dbo.Users_UpdatedByUser] FOREIGN KEY([UpdatedByUserId])
REFERENCES [dbo].[Users] ([ID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.QueryCategories_dbo.Users_UpdatedByUser]') AND parent_object_id = OBJECT_ID(N'[dbo].[QueryCategories]'))
ALTER TABLE [dbo].[QueryCategories] CHECK CONSTRAINT [FK_dbo.QueryCategories_dbo.Users_UpdatedByUser]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.QueryCategories_dbo.Users_User_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[QueryCategories]'))
ALTER TABLE [dbo].[QueryCategories]  WITH CHECK ADD  CONSTRAINT [FK_dbo.QueryCategories_dbo.Users_User_ID] FOREIGN KEY([User_ID])
REFERENCES [dbo].[Users] ([ID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.QueryCategories_dbo.Users_User_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[QueryCategories]'))
ALTER TABLE [dbo].[QueryCategories] CHECK CONSTRAINT [FK_dbo.QueryCategories_dbo.Users_User_ID]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_QueryCategories_Users]') AND parent_object_id = OBJECT_ID(N'[dbo].[QueryCategories]'))
ALTER TABLE [dbo].[QueryCategories]  WITH CHECK ADD  CONSTRAINT [FK_QueryCategories_Users] FOREIGN KEY([CreatedByUserId])
REFERENCES [dbo].[Users] ([ID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_QueryCategories_Users]') AND parent_object_id = OBJECT_ID(N'[dbo].[QueryCategories]'))
ALTER TABLE [dbo].[QueryCategories] CHECK CONSTRAINT [FK_QueryCategories_Users]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_QueryCategoryQueries_Queries]') AND parent_object_id = OBJECT_ID(N'[dbo].[QueryCategoryQueries]'))
ALTER TABLE [dbo].[QueryCategoryQueries]  WITH CHECK ADD  CONSTRAINT [FK_QueryCategoryQueries_Queries] FOREIGN KEY([Query_Id])
REFERENCES [dbo].[Queries] ([Id])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_QueryCategoryQueries_Queries]') AND parent_object_id = OBJECT_ID(N'[dbo].[QueryCategoryQueries]'))
ALTER TABLE [dbo].[QueryCategoryQueries] CHECK CONSTRAINT [FK_QueryCategoryQueries_Queries]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.QueryParameters_dbo.Queries_QueryId]') AND parent_object_id = OBJECT_ID(N'[dbo].[QueryParameters]'))
ALTER TABLE [dbo].[QueryParameters]  WITH CHECK ADD  CONSTRAINT [FK_dbo.QueryParameters_dbo.Queries_QueryId] FOREIGN KEY([QueryId])
REFERENCES [dbo].[Queries] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.QueryParameters_dbo.Queries_QueryId]') AND parent_object_id = OBJECT_ID(N'[dbo].[QueryParameters]'))
ALTER TABLE [dbo].[QueryParameters] CHECK CONSTRAINT [FK_dbo.QueryParameters_dbo.Queries_QueryId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ReceivedSMs_dbo.Facilities_FacCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[ReceivedSMS]'))
ALTER TABLE [dbo].[ReceivedSMS]  WITH CHECK ADD  CONSTRAINT [FK_dbo.ReceivedSMs_dbo.Facilities_FacCode] FOREIGN KEY([FacCode])
REFERENCES [dbo].[Facilities] ([FacCode])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ReceivedSMs_dbo.Facilities_FacCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[ReceivedSMS]'))
ALTER TABLE [dbo].[ReceivedSMS] CHECK CONSTRAINT [FK_dbo.ReceivedSMs_dbo.Facilities_FacCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ReceivedSMS_Facilities]') AND parent_object_id = OBJECT_ID(N'[dbo].[ReceivedSMS]'))
ALTER TABLE [dbo].[ReceivedSMS]  WITH CHECK ADD  CONSTRAINT [FK_ReceivedSMS_Facilities] FOREIGN KEY([FacCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ReceivedSMS_Facilities]') AND parent_object_id = OBJECT_ID(N'[dbo].[ReceivedSMS]'))
ALTER TABLE [dbo].[ReceivedSMS] CHECK CONSTRAINT [FK_ReceivedSMS_Facilities]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ReceivedSMS_Report]') AND parent_object_id = OBJECT_ID(N'[dbo].[ReceivedSMS]'))
ALTER TABLE [dbo].[ReceivedSMS]  WITH CHECK ADD  CONSTRAINT [FK_ReceivedSMS_Report] FOREIGN KEY([RepID])
REFERENCES [dbo].[Report] ([RepID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ReceivedSMS_Report]') AND parent_object_id = OBJECT_ID(N'[dbo].[ReceivedSMS]'))
ALTER TABLE [dbo].[ReceivedSMS] CHECK CONSTRAINT [FK_ReceivedSMS_Report]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ReportBusinessRules_Report]') AND parent_object_id = OBJECT_ID(N'[dbo].[ReportBusinessRules]'))
ALTER TABLE [dbo].[ReportBusinessRules]  WITH CHECK ADD  CONSTRAINT [FK_ReportBusinessRules_Report] FOREIGN KEY([RepID])
REFERENCES [dbo].[Report] ([RepID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ReportBusinessRules_Report]') AND parent_object_id = OBJECT_ID(N'[dbo].[ReportBusinessRules]'))
ALTER TABLE [dbo].[ReportBusinessRules] CHECK CONSTRAINT [FK_ReportBusinessRules_Report]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ReportData_ReceivedSMS]') AND parent_object_id = OBJECT_ID(N'[dbo].[ReportData]'))
ALTER TABLE [dbo].[ReportData]  WITH CHECK ADD  CONSTRAINT [FK_ReportData_ReceivedSMS] FOREIGN KEY([ReceivedSMSNo])
REFERENCES [dbo].[ReceivedSMS] ([ReceivedSMSNo])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ReportData_ReceivedSMS]') AND parent_object_id = OBJECT_ID(N'[dbo].[ReportData]'))
ALTER TABLE [dbo].[ReportData] CHECK CONSTRAINT [FK_ReportData_ReceivedSMS]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ReportData_Report]') AND parent_object_id = OBJECT_ID(N'[dbo].[ReportData]'))
ALTER TABLE [dbo].[ReportData]  WITH CHECK ADD  CONSTRAINT [FK_ReportData_Report] FOREIGN KEY([RepID])
REFERENCES [dbo].[Report] ([RepID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ReportData_Report]') AND parent_object_id = OBJECT_ID(N'[dbo].[ReportData]'))
ALTER TABLE [dbo].[ReportData] CHECK CONSTRAINT [FK_ReportData_Report]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ReportDataLocations_Report]') AND parent_object_id = OBJECT_ID(N'[dbo].[ReportDataLocations]'))
ALTER TABLE [dbo].[ReportDataLocations]  WITH CHECK ADD  CONSTRAINT [FK_ReportDataLocations_Report] FOREIGN KEY([RepID])
REFERENCES [dbo].[Report] ([RepID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ReportDataLocations_Report]') AND parent_object_id = OBJECT_ID(N'[dbo].[ReportDataLocations]'))
ALTER TABLE [dbo].[ReportDataLocations] CHECK CONSTRAINT [FK_ReportDataLocations_Report]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ReportDataMerging_dbo.ReportMerge_MergeId]') AND parent_object_id = OBJECT_ID(N'[dbo].[ReportDataMerging]'))
ALTER TABLE [dbo].[ReportDataMerging]  WITH CHECK ADD  CONSTRAINT [FK_dbo.ReportDataMerging_dbo.ReportMerge_MergeId] FOREIGN KEY([MergeId])
REFERENCES [dbo].[ReportMerge] ([MergeId])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ReportDataMerging_dbo.ReportMerge_MergeId]') AND parent_object_id = OBJECT_ID(N'[dbo].[ReportDataMerging]'))
ALTER TABLE [dbo].[ReportDataMerging] CHECK CONSTRAINT [FK_dbo.ReportDataMerging_dbo.ReportMerge_MergeId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ReportDataSetElementsLinks_dbo.ReportDataLocations_ReportIndicatorId]') AND parent_object_id = OBJECT_ID(N'[dbo].[ReportDataSetElementsLinks]'))
ALTER TABLE [dbo].[ReportDataSetElementsLinks]  WITH CHECK ADD  CONSTRAINT [FK_dbo.ReportDataSetElementsLinks_dbo.ReportDataLocations_ReportIndicatorId] FOREIGN KEY([ReportIndicatorId])
REFERENCES [dbo].[ReportDataLocations] ([MeasureNo])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ReportDataSetElementsLinks_dbo.ReportDataLocations_ReportIndicatorId]') AND parent_object_id = OBJECT_ID(N'[dbo].[ReportDataSetElementsLinks]'))
ALTER TABLE [dbo].[ReportDataSetElementsLinks] CHECK CONSTRAINT [FK_dbo.ReportDataSetElementsLinks_dbo.ReportDataLocations_ReportIndicatorId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ReportDataSetElementsLinks_dbo.ReportDataSetLinks_ReportDataSetLinkId]') AND parent_object_id = OBJECT_ID(N'[dbo].[ReportDataSetElementsLinks]'))
ALTER TABLE [dbo].[ReportDataSetElementsLinks]  WITH CHECK ADD  CONSTRAINT [FK_dbo.ReportDataSetElementsLinks_dbo.ReportDataSetLinks_ReportDataSetLinkId] FOREIGN KEY([ReportDataSetLinkId])
REFERENCES [dbo].[ReportDataSetLinks] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ReportDataSetElementsLinks_dbo.ReportDataSetLinks_ReportDataSetLinkId]') AND parent_object_id = OBJECT_ID(N'[dbo].[ReportDataSetElementsLinks]'))
ALTER TABLE [dbo].[ReportDataSetElementsLinks] CHECK CONSTRAINT [FK_dbo.ReportDataSetElementsLinks_dbo.ReportDataSetLinks_ReportDataSetLinkId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ReportDataSetLinks_dbo.Report_ReportId]') AND parent_object_id = OBJECT_ID(N'[dbo].[ReportDataSetLinks]'))
ALTER TABLE [dbo].[ReportDataSetLinks]  WITH CHECK ADD  CONSTRAINT [FK_dbo.ReportDataSetLinks_dbo.Report_ReportId] FOREIGN KEY([ReportId])
REFERENCES [dbo].[Report] ([RepID])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.ReportDataSetLinks_dbo.Report_ReportId]') AND parent_object_id = OBJECT_ID(N'[dbo].[ReportDataSetLinks]'))
ALTER TABLE [dbo].[ReportDataSetLinks] CHECK CONSTRAINT [FK_dbo.ReportDataSetLinks_dbo.Report_ReportId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SMSReminderTracker_Facilities]') AND parent_object_id = OBJECT_ID(N'[dbo].[SMSReminderTracker]'))
ALTER TABLE [dbo].[SMSReminderTracker]  WITH CHECK ADD  CONSTRAINT [FK_SMSReminderTracker_Facilities] FOREIGN KEY([FacCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SMSReminderTracker_Facilities]') AND parent_object_id = OBJECT_ID(N'[dbo].[SMSReminderTracker]'))
ALTER TABLE [dbo].[SMSReminderTracker] CHECK CONSTRAINT [FK_SMSReminderTracker_Facilities]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SMSReminderTracker_Report]') AND parent_object_id = OBJECT_ID(N'[dbo].[SMSReminderTracker]'))
ALTER TABLE [dbo].[SMSReminderTracker]  WITH CHECK ADD  CONSTRAINT [FK_SMSReminderTracker_Report] FOREIGN KEY([ReportID])
REFERENCES [dbo].[Report] ([RepID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SMSReminderTracker_Report]') AND parent_object_id = OBJECT_ID(N'[dbo].[SMSReminderTracker]'))
ALTER TABLE [dbo].[SMSReminderTracker] CHECK CONSTRAINT [FK_SMSReminderTracker_Report]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.StockStatus_dbo.Facilities_FacCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[StockStatus]'))
ALTER TABLE [dbo].[StockStatus]  WITH CHECK ADD  CONSTRAINT [FK_dbo.StockStatus_dbo.Facilities_FacCode] FOREIGN KEY([FacCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.StockStatus_dbo.Facilities_FacCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[StockStatus]'))
ALTER TABLE [dbo].[StockStatus] CHECK CONSTRAINT [FK_dbo.StockStatus_dbo.Facilities_FacCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.TestingAndCounselingDatas_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[TestingAndCounselingDatas]'))
ALTER TABLE [dbo].[TestingAndCounselingDatas]  WITH CHECK ADD  CONSTRAINT [FK_dbo.TestingAndCounselingDatas_dbo.Facilities_FacilityCode] FOREIGN KEY([FacilityCode])
REFERENCES [dbo].[Facilities] ([FacCode])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.TestingAndCounselingDatas_dbo.Facilities_FacilityCode]') AND parent_object_id = OBJECT_ID(N'[dbo].[TestingAndCounselingDatas]'))
ALTER TABLE [dbo].[TestingAndCounselingDatas] CHECK CONSTRAINT [FK_dbo.TestingAndCounselingDatas_dbo.Facilities_FacilityCode]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.TestingAndCounselingDatas_dbo.TestingAndCounselings_CounselingAndTestingId]') AND parent_object_id = OBJECT_ID(N'[dbo].[TestingAndCounselingDatas]'))
ALTER TABLE [dbo].[TestingAndCounselingDatas]  WITH CHECK ADD  CONSTRAINT [FK_dbo.TestingAndCounselingDatas_dbo.TestingAndCounselings_CounselingAndTestingId] FOREIGN KEY([CounselingAndTestingId])
REFERENCES [dbo].[TestingAndCounselings] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.TestingAndCounselingDatas_dbo.TestingAndCounselings_CounselingAndTestingId]') AND parent_object_id = OBJECT_ID(N'[dbo].[TestingAndCounselingDatas]'))
ALTER TABLE [dbo].[TestingAndCounselingDatas] CHECK CONSTRAINT [FK_dbo.TestingAndCounselingDatas_dbo.TestingAndCounselings_CounselingAndTestingId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.TestingAndCounselingDatas_dbo.Timeframes_TimeframeId]') AND parent_object_id = OBJECT_ID(N'[dbo].[TestingAndCounselingDatas]'))
ALTER TABLE [dbo].[TestingAndCounselingDatas]  WITH CHECK ADD  CONSTRAINT [FK_dbo.TestingAndCounselingDatas_dbo.Timeframes_TimeframeId] FOREIGN KEY([TimeframeId])
REFERENCES [dbo].[Timeframes] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.TestingAndCounselingDatas_dbo.Timeframes_TimeframeId]') AND parent_object_id = OBJECT_ID(N'[dbo].[TestingAndCounselingDatas]'))
ALTER TABLE [dbo].[TestingAndCounselingDatas] CHECK CONSTRAINT [FK_dbo.TestingAndCounselingDatas_dbo.Timeframes_TimeframeId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.TestingAndCounselingDatas_dbo.Users_UserId]') AND parent_object_id = OBJECT_ID(N'[dbo].[TestingAndCounselingDatas]'))
ALTER TABLE [dbo].[TestingAndCounselingDatas]  WITH CHECK ADD  CONSTRAINT [FK_dbo.TestingAndCounselingDatas_dbo.Users_UserId] FOREIGN KEY([UserId])
REFERENCES [dbo].[Users] ([ID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.TestingAndCounselingDatas_dbo.Users_UserId]') AND parent_object_id = OBJECT_ID(N'[dbo].[TestingAndCounselingDatas]'))
ALTER TABLE [dbo].[TestingAndCounselingDatas] CHECK CONSTRAINT [FK_dbo.TestingAndCounselingDatas_dbo.Users_UserId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.Translations_dbo.Languages_LangID]') AND parent_object_id = OBJECT_ID(N'[dbo].[Translations]'))
ALTER TABLE [dbo].[Translations]  WITH CHECK ADD  CONSTRAINT [FK_dbo.Translations_dbo.Languages_LangID] FOREIGN KEY([LangID])
REFERENCES [dbo].[Languages] ([LangID])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.Translations_dbo.Languages_LangID]') AND parent_object_id = OBJECT_ID(N'[dbo].[Translations]'))
ALTER TABLE [dbo].[Translations] CHECK CONSTRAINT [FK_dbo.Translations_dbo.Languages_LangID]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Translations_Languages]') AND parent_object_id = OBJECT_ID(N'[dbo].[Translations]'))
ALTER TABLE [dbo].[Translations]  WITH CHECK ADD  CONSTRAINT [FK_Translations_Languages] FOREIGN KEY([LangID])
REFERENCES [dbo].[Languages] ([LangID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Translations_Languages]') AND parent_object_id = OBJECT_ID(N'[dbo].[Translations]'))
ALTER TABLE [dbo].[Translations] CHECK CONSTRAINT [FK_Translations_Languages]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.TripReportDistricts_dbo.District_DistrictId]') AND parent_object_id = OBJECT_ID(N'[dbo].[TripReportDistricts]'))
ALTER TABLE [dbo].[TripReportDistricts]  WITH CHECK ADD  CONSTRAINT [FK_dbo.TripReportDistricts_dbo.District_DistrictId] FOREIGN KEY([DistrictId])
REFERENCES [dbo].[District] ([DistrictNo])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.TripReportDistricts_dbo.District_DistrictId]') AND parent_object_id = OBJECT_ID(N'[dbo].[TripReportDistricts]'))
ALTER TABLE [dbo].[TripReportDistricts] CHECK CONSTRAINT [FK_dbo.TripReportDistricts_dbo.District_DistrictId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.TripReportDistricts_dbo.TripReports_TripReportId]') AND parent_object_id = OBJECT_ID(N'[dbo].[TripReportDistricts]'))
ALTER TABLE [dbo].[TripReportDistricts]  WITH CHECK ADD  CONSTRAINT [FK_dbo.TripReportDistricts_dbo.TripReports_TripReportId] FOREIGN KEY([TripReportId])
REFERENCES [dbo].[TripReports] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.TripReportDistricts_dbo.TripReports_TripReportId]') AND parent_object_id = OBJECT_ID(N'[dbo].[TripReportDistricts]'))
ALTER TABLE [dbo].[TripReportDistricts] CHECK CONSTRAINT [FK_dbo.TripReportDistricts_dbo.TripReports_TripReportId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.TripReportMonths_dbo.TripReports_TripReportId]') AND parent_object_id = OBJECT_ID(N'[dbo].[TripReportMonths]'))
ALTER TABLE [dbo].[TripReportMonths]  WITH CHECK ADD  CONSTRAINT [FK_dbo.TripReportMonths_dbo.TripReports_TripReportId] FOREIGN KEY([TripReportId])
REFERENCES [dbo].[TripReports] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.TripReportMonths_dbo.TripReports_TripReportId]') AND parent_object_id = OBJECT_ID(N'[dbo].[TripReportMonths]'))
ALTER TABLE [dbo].[TripReportMonths] CHECK CONSTRAINT [FK_dbo.TripReportMonths_dbo.TripReports_TripReportId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.TripReports_dbo.Activities_SpecialActivityId]') AND parent_object_id = OBJECT_ID(N'[dbo].[TripReports]'))
ALTER TABLE [dbo].[TripReports]  WITH CHECK ADD  CONSTRAINT [FK_dbo.TripReports_dbo.Activities_SpecialActivityId] FOREIGN KEY([SpecialActivityId])
REFERENCES [dbo].[Activities] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.TripReports_dbo.Activities_SpecialActivityId]') AND parent_object_id = OBJECT_ID(N'[dbo].[TripReports]'))
ALTER TABLE [dbo].[TripReports] CHECK CONSTRAINT [FK_dbo.TripReports_dbo.Activities_SpecialActivityId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.TripReports_dbo.Users_CreatedByUserId]') AND parent_object_id = OBJECT_ID(N'[dbo].[TripReports]'))
ALTER TABLE [dbo].[TripReports]  WITH CHECK ADD  CONSTRAINT [FK_dbo.TripReports_dbo.Users_CreatedByUserId] FOREIGN KEY([CreatedByUserId])
REFERENCES [dbo].[Users] ([ID])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.TripReports_dbo.Users_CreatedByUserId]') AND parent_object_id = OBJECT_ID(N'[dbo].[TripReports]'))
ALTER TABLE [dbo].[TripReports] CHECK CONSTRAINT [FK_dbo.TripReports_dbo.Users_CreatedByUserId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.Users_dbo.AccessLevels_AccessLevelID]') AND parent_object_id = OBJECT_ID(N'[dbo].[Users]'))
ALTER TABLE [dbo].[Users]  WITH CHECK ADD  CONSTRAINT [FK_dbo.Users_dbo.AccessLevels_AccessLevelID] FOREIGN KEY([AccessLevelID])
REFERENCES [dbo].[AccessLevels] ([AccessID])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.Users_dbo.AccessLevels_AccessLevelID]') AND parent_object_id = OBJECT_ID(N'[dbo].[Users]'))
ALTER TABLE [dbo].[Users] CHECK CONSTRAINT [FK_dbo.Users_dbo.AccessLevels_AccessLevelID]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.Users_dbo.SupportingPartners_SupportingPartnerId]') AND parent_object_id = OBJECT_ID(N'[dbo].[Users]'))
ALTER TABLE [dbo].[Users]  WITH CHECK ADD  CONSTRAINT [FK_dbo.Users_dbo.SupportingPartners_SupportingPartnerId] FOREIGN KEY([SupportingPartnerId])
REFERENCES [dbo].[SupportingPartners] ([Id])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.Users_dbo.SupportingPartners_SupportingPartnerId]') AND parent_object_id = OBJECT_ID(N'[dbo].[Users]'))
ALTER TABLE [dbo].[Users] CHECK CONSTRAINT [FK_dbo.Users_dbo.SupportingPartners_SupportingPartnerId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.webpages_RolesUser_dbo.Users_User_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[webpages_RolesUser]'))
ALTER TABLE [dbo].[webpages_RolesUser]  WITH CHECK ADD  CONSTRAINT [FK_dbo.webpages_RolesUser_dbo.Users_User_ID] FOREIGN KEY([User_ID])
REFERENCES [dbo].[Users] ([ID])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.webpages_RolesUser_dbo.Users_User_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[webpages_RolesUser]'))
ALTER TABLE [dbo].[webpages_RolesUser] CHECK CONSTRAINT [FK_dbo.webpages_RolesUser_dbo.Users_User_ID]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.webpages_RolesUser_dbo.webpages_Roles_webpages_Roles_RoleId]') AND parent_object_id = OBJECT_ID(N'[dbo].[webpages_RolesUser]'))
ALTER TABLE [dbo].[webpages_RolesUser]  WITH CHECK ADD  CONSTRAINT [FK_dbo.webpages_RolesUser_dbo.webpages_Roles_webpages_Roles_RoleId] FOREIGN KEY([webpages_Roles_RoleId])
REFERENCES [dbo].[webpages_Roles] ([RoleId])
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_dbo.webpages_RolesUser_dbo.webpages_Roles_webpages_Roles_RoleId]') AND parent_object_id = OBJECT_ID(N'[dbo].[webpages_RolesUser]'))
ALTER TABLE [dbo].[webpages_RolesUser] CHECK CONSTRAINT [FK_dbo.webpages_RolesUser_dbo.webpages_Roles_webpages_Roles_RoleId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[fk_RoleId]') AND parent_object_id = OBJECT_ID(N'[dbo].[webpages_UsersInRoles]'))
ALTER TABLE [dbo].[webpages_UsersInRoles]  WITH CHECK ADD  CONSTRAINT [fk_RoleId] FOREIGN KEY([RoleId])
REFERENCES [dbo].[webpages_Roles] ([RoleId])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[fk_RoleId]') AND parent_object_id = OBJECT_ID(N'[dbo].[webpages_UsersInRoles]'))
ALTER TABLE [dbo].[webpages_UsersInRoles] CHECK CONSTRAINT [fk_RoleId]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[fk_UserId]') AND parent_object_id = OBJECT_ID(N'[dbo].[webpages_UsersInRoles]'))
ALTER TABLE [dbo].[webpages_UsersInRoles]  WITH CHECK ADD  CONSTRAINT [fk_UserId] FOREIGN KEY([UserId])
REFERENCES [dbo].[UserProfile] ([UserId])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[fk_UserId]') AND parent_object_id = OBJECT_ID(N'[dbo].[webpages_UsersInRoles]'))
ALTER TABLE [dbo].[webpages_UsersInRoles] CHECK CONSTRAINT [fk_UserId]
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'ANCForm', N'COLUMN',N'HudhurioLaKwanza_2id'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Links with Hudhurio la kwanza section, stored in ANCForm_HudhurioLaKwanza' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ANCForm', @level2type=N'COLUMN',@level2name=N'HudhurioLaKwanza_2id'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'ANCForm', N'COLUMN',N'VidokezoVyaHatari_4id'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Links with Vidokezo vya Hatari, stored in ANCForm_VidokezoVyaHatari table' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ANCForm', @level2type=N'COLUMN',@level2name=N'VidokezoVyaHatari_4id'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'ANCForm', N'COLUMN',N'PMTCT_5id'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Links with PMTCT section, stored in ANCForm_PMTCT' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ANCForm', @level2type=N'COLUMN',@level2name=N'PMTCT_5id'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'ANCForm', N'COLUMN',N'Malaria_6id'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Links with Malaria, stored in ANCForm_Malaria' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ANCForm', @level2type=N'COLUMN',@level2name=N'Malaria_6id'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'ANCForm_Malaria', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Malaria - Taarifa ya Mwezi Toka Kliniki (ANC)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ANCForm_Malaria'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'ANCForm_PMTCT', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'PMTCT - Taarifa ya Mwezi Toka Kliniki (ANC)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ANCForm_PMTCT'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'ANCForm_VidokezoVyaHatari', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Vidokezo vya Hatari - Taarifa ya Mwezi Toka Kliniki (ANC)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ANCForm_VidokezoVyaHatari'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'MobilePhoneOperators', N'COLUMN',N'MCC'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'MCC is Mobile Country Code. It is used for identifying mobile stations in wireless telephone networks, particularly GSM and UMTS networks. An MCC if often used in combination with a Mobile Network Code (as a "MCC/MNC tuple") in order to uniquely identify a network operator.

The MCC is part of the International Mobile Subscriber Identity (IMSI) number, which uniquely identifies a particular subscriber, and is stored on a (usually) removable SIM card. The current MCC (i.e. the country in which the modem in now) may be also be obtained from a GSM/UMTS wireless modem using the AT command AT+COPS.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'MobilePhoneOperators', @level2type=N'COLUMN',@level2name=N'MCC'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'MobilePhoneOperators', N'COLUMN',N'MNC'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Mobile Network Code (MNC) is used in combination with a Mobile Country Code (MCC) (also known as a "MCC/MNC tuple") to uniquely identify a mobile phone operator/carrier using GSM/LTE, CDMA, iDEN, TETRA and UMTS public land mobile networks and some satellite mobile networks.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'MobilePhoneOperators', @level2type=N'COLUMN',@level2name=N'MNC'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'PresetChartsIndicators', N'COLUMN',N'IndicatorDefinition'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This field will hold simple and complex indicator definition. Simple indicator will this format [RepID from Report table].[Position of indicator in ReportData table]. For example 2.8 means the indicator gets it data from position 8 in ReportData table of the report identified by RepID 2.

Complex indicator definition may include operators like +, -, * and / separated by space from simple indicator e.g. 3.7 + 2.10 - 4.5' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PresetChartsIndicators', @level2type=N'COLUMN',@level2name=N'IndicatorDefinition'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'ReportDataMerging', N'COLUMN',N'DestinationIndicator'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Holds the destination indicator definition in this format: {ReportId}.Report Indicator Shortcode e.g. {6}.ANC02' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ReportDataMerging', @level2type=N'COLUMN',@level2name=N'DestinationIndicator'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'ReportDataMerging', N'COLUMN',N'SourceIndicator'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Holds the sournce indicator definition in this format: {ReportId}.Report Indicator Shortcode. This field can contain operation or constants e.g. {6}.ANC02,+,{7}.PCR02,-,[5]' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ReportDataMerging', @level2type=N'COLUMN',@level2name=N'SourceIndicator'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPane1' , N'SCHEMA',N'dbo', N'VIEW',N'ANC', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[25] 4[13] 2[43] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4[30] 2[40] 3) )"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2[66] 3) )"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 5
   End
   Begin DiagramPane = 
      PaneHidden = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
      Begin ColumnWidths = 20
         Width = 284
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
      End
   End
   Begin CriteriaPane = 
      PaneHidden = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'ANC'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPaneCount' , N'SCHEMA',N'dbo', N'VIEW',N'ANC', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'ANC'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPane1' , N'SCHEMA',N'dbo', N'VIEW',N'count_facilities', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "Facilities"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 135
               Right = 251
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Region"
            Begin Extent = 
               Top = 6
               Left = 289
               Bottom = 118
               Right = 475
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "District"
            Begin Extent = 
               Top = 6
               Left = 513
               Bottom = 135
               Right = 699
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 12
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'count_facilities'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPaneCount' , N'SCHEMA',N'dbo', N'VIEW',N'count_facilities', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'count_facilities'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPane1' , N'SCHEMA',N'dbo', N'VIEW',N'eid_facilities', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "Facilities"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 135
               Right = 235
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "District"
            Begin Extent = 
               Top = 6
               Left = 273
               Bottom = 135
               Right = 443
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Region"
            Begin Extent = 
               Top = 6
               Left = 481
               Bottom = 118
               Right = 651
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'eid_facilities'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPaneCount' , N'SCHEMA',N'dbo', N'VIEW',N'eid_facilities', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'eid_facilities'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPane1' , N'SCHEMA',N'dbo', N'VIEW',N'eid_facilities_count', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2[66] 3) )"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2) )"
      End
      ActivePaneConfig = 5
   End
   Begin DiagramPane = 
      PaneHidden = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "Facilities"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 135
               Right = 251
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "District"
            Begin Extent = 
               Top = 6
               Left = 289
               Bottom = 135
               Right = 475
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Region"
            Begin Extent = 
               Top = 6
               Left = 513
               Bottom = 118
               Right = 699
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      PaneHidden = 
      Begin ColumnWidths = 12
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'eid_facilities_count'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPaneCount' , N'SCHEMA',N'dbo', N'VIEW',N'eid_facilities_count', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'eid_facilities_count'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPane1' , N'SCHEMA',N'dbo', N'VIEW',N'facilities_count_dispensaries', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "Facilities"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 135
               Right = 235
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Region"
            Begin Extent = 
               Top = 6
               Left = 273
               Bottom = 118
               Right = 443
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "District"
            Begin Extent = 
               Top = 6
               Left = 481
               Bottom = 135
               Right = 651
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'facilities_count_dispensaries'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPaneCount' , N'SCHEMA',N'dbo', N'VIEW',N'facilities_count_dispensaries', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'facilities_count_dispensaries'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPane1' , N'SCHEMA',N'dbo', N'VIEW',N'facilities_count_health_centres', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "Facilities"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 135
               Right = 235
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Region"
            Begin Extent = 
               Top = 6
               Left = 273
               Bottom = 118
               Right = 443
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "District"
            Begin Extent = 
               Top = 6
               Left = 481
               Bottom = 135
               Right = 651
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'facilities_count_health_centres'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPaneCount' , N'SCHEMA',N'dbo', N'VIEW',N'facilities_count_health_centres', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'facilities_count_health_centres'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPane1' , N'SCHEMA',N'dbo', N'VIEW',N'facilities_count_hospitals', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "Facilities"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 135
               Right = 235
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Region"
            Begin Extent = 
               Top = 6
               Left = 273
               Bottom = 118
               Right = 443
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "District"
            Begin Extent = 
               Top = 6
               Left = 481
               Bottom = 135
               Right = 651
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'facilities_count_hospitals'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPaneCount' , N'SCHEMA',N'dbo', N'VIEW',N'facilities_count_hospitals', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'facilities_count_hospitals'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPane1' , N'SCHEMA',N'dbo', N'VIEW',N'facilities_count_types', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "Facilities"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 135
               Right = 251
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "FacilityType"
            Begin Extent = 
               Top = 6
               Left = 289
               Bottom = 118
               Right = 480
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 12
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'facilities_count_types'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPaneCount' , N'SCHEMA',N'dbo', N'VIEW',N'facilities_count_types', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'facilities_count_types'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPane1' , N'SCHEMA',N'dbo', N'VIEW',N'facilities_count_types_districts', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "Region"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 118
               Right = 208
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "District"
            Begin Extent = 
               Top = 6
               Left = 246
               Bottom = 135
               Right = 416
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'facilities_count_types_districts'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPaneCount' , N'SCHEMA',N'dbo', N'VIEW',N'facilities_count_types_districts', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'facilities_count_types_districts'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPane1' , N'SCHEMA',N'dbo', N'VIEW',N'FacilitiesReports', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "ReportData"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 125
               Right = 204
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "ReceivedSMS"
            Begin Extent = 
               Top = 6
               Left = 242
               Bottom = 125
               Right = 408
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Facilities"
            Begin Extent = 
               Top = 6
               Left = 446
               Bottom = 125
               Right = 606
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "District"
            Begin Extent = 
               Top = 6
               Left = 644
               Bottom = 95
               Right = 804
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Region"
            Begin Extent = 
               Top = 96
               Left = 644
               Bottom = 185
               Right = 804
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
      Begin ColumnWidths = 9
         Width = 284
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
   ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'FacilitiesReports'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPane2' , N'SCHEMA',N'dbo', N'VIEW',N'FacilitiesReports', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane2', @value=N'      Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'FacilitiesReports'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPaneCount' , N'SCHEMA',N'dbo', N'VIEW',N'FacilitiesReports', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=2 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'FacilitiesReports'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPane1' , N'SCHEMA',N'dbo', N'VIEW',N'MAT', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
      Begin ColumnWidths = 9
         Width = 284
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'MAT'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPaneCount' , N'SCHEMA',N'dbo', N'VIEW',N'MAT', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'MAT'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPane1' , N'SCHEMA',N'dbo', N'VIEW',N'MC', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
      Begin ColumnWidths = 9
         Width = 284
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'MC'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPaneCount' , N'SCHEMA',N'dbo', N'VIEW',N'MC', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'MC'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPane1' , N'SCHEMA',N'dbo', N'VIEW',N'PCR', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
      Begin ColumnWidths = 9
         Width = 284
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'PCR'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPaneCount' , N'SCHEMA',N'dbo', N'VIEW',N'PCR', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'PCR'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPane1' , N'SCHEMA',N'dbo', N'VIEW',N'PositiveTotalTested', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "Facilities"
            Begin Extent = 
               Top = 8
               Left = 232
               Bottom = 123
               Right = 415
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "District"
            Begin Extent = 
               Top = 149
               Left = 450
               Bottom = 264
               Right = 602
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "ANC"
            Begin Extent = 
               Top = 7
               Left = 497
               Bottom = 122
               Right = 655
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Region"
            Begin Extent = 
               Top = 149
               Left = 16
               Bottom = 234
               Right = 168
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'PositiveTotalTested'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPaneCount' , N'SCHEMA',N'dbo', N'VIEW',N'PositiveTotalTested', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'PositiveTotalTested'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPane1' , N'SCHEMA',N'dbo', N'VIEW',N'users_SMS', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "ApprovedSMSCells"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 135
               Right = 215
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Facilities"
            Begin Extent = 
               Top = 6
               Left = 253
               Bottom = 135
               Right = 450
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "District"
            Begin Extent = 
               Top = 6
               Left = 488
               Bottom = 135
               Right = 658
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Languages"
            Begin Extent = 
               Top = 6
               Left = 696
               Bottom = 101
               Right = 866
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Region"
            Begin Extent = 
               Top = 6
               Left = 904
               Bottom = 118
               Right = 1074
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
       ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'users_SMS'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPane2' , N'SCHEMA',N'dbo', N'VIEW',N'users_SMS', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane2', @value=N'  Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'users_SMS'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_DiagramPaneCount' , N'SCHEMA',N'dbo', N'VIEW',N'users_SMS', NULL,NULL))
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=2 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'users_SMS'
GO
